C-Command Software Forum

Memory Usage and Whitelist/Blocklist purge

SpamSieve appears to be using 2.6 Gb of memory. I have been using the app for over 10 years and have almost 1M whitelist and 500K blocklist entries. The vast majority have no hits. Can these be successfully deleted?

Yes, you can greatly decrease the memory use and launch time by deleting rules with no hits. The downside would be that it’s possible there are some recently added rules that don’t yet have any hits but which you would want to keep.

Can I arrange by number of hits, highlight the zeroes, re-sort by date while all the zeroes remain highlighted, then option click the most recent ones to remove from delete list?

Yes, that’s a good way to do it, except that I think you want Command rather than Option.

Sounds like a great AppleScript opportunity… for each rule in the rule in the rule list whose creation date > 1 year from today, and whose hits = 0… delete :slight_smile:

Thanks. SpamSieve crashes (beachballs) when I try to sort more than about 100 or so whitelist entries. As I have almost a million it will take forever to do it <100 at a time.

I’ll have to try a script to do them one at a time. However, I downloaded a “delete SPAM” script about 5 years ago and it didn’t work for me but I’m not that knowledgeable about scripts.

I don’t understand where the “100” is coming from. It’s going to sort the whole window no matter how many rules are selected, so it may take a while to change the sort order but you would only need to wait once. Doing it with AppleScript would almost certainly be slower and use a lot of memory.

I have the same problem with a whitelist going back to 2003 that I think it would be a good idea to reduce. I sorted by hits, selected the zeroes and then sorted by date. No problems there. However, I can’t find how to deselect the recent entries more than one at a time. Deselecting one by one is not an option, there are too many of them.

Any suggestions?

As far as I know, macOS tables don’t have an easy way to batch-deselect a discontiguous range. If you can, I would wait until the next major version of SpamSieve. Then this will be easier because it will be possible to secondary sort in rules windows, so that you can easily select what you want to delete. Also, batch rule deletion will be more efficient. Right now it can be pretty slow if you have a lot of rules.

Today, two options are:

  1. After sorting by date, you could Copy the zero-hit rules to the clipboard. Delete the selected rules. Then you could paste the addresses into a text file (where they’ll still be sorted by date) and range-select to delete the old ones at the top. Then import the text file of new addresses back into SpamSieve’s whitelist. (Only From (address) Is Equal To rules can be recreated in this way, but those are the most important.)

  2. Run an AppleScript like this one to delete the zero-hit rules that are older than (in this case) 2 years. However, you may find that in SpamSieve 2.x this is very slow and uses a lot of memory.

tell application "SpamSieve"
    set _date to my yearsAgo(2)
    with timeout of 24 * 60 * 60 seconds
        tell whitelist
            delete (every rule whose hits = 0 and creation date < _date)
        end tell
    end timeout
end tell

on yearsAgo(_years)
    set _date to current date
    set year of _date to (year of _date) - _years
    return _date
end yearsAgo

I think I’ll try your proposed methods in reverse order: first, AppleScript, then the text file, and finally wait for SpamSieve 3.

I have 64 GB of memory and can launch it this evening so even if it eats all the RAM and takes hours, it won’t be a problem. Unless it crashes or isn’t done the next morning.

Did you choose two years arbitrarily or for some specific reason? I was planning on keeping around five years, for no good reason, just gut feeling.

Just a gut feeling. You could always start with keeping 5 years and delete more later if you want.

@Michael_Tsai

The script worked like a charm. And fast too. I hardly had the time to notice it was running and it was done!

It reduced the number of rules in the whitelist from over 37000 to just over 9700. I used the two year limit since I figured your gut feeling was probably better than mine.

The blocklist has 16800 rules, going back to 2003. The vast majority of them have zero hits. Would it be useful to reduce it too?

Yes, although it sounds like there is less room for a speedup there.