Swapping like crazy

I’ve noticed that my Mac seems to be eating up quite a bit of disk space every now and then, without any action from me. I have MenuMeters installed and realized that this extra disk usage is due to insane swap-file usage. I know one cannot rely completely on the reported RAM usage numbers (“used” vs “free” due to all the other states, “free”, “wired”, “active”, “inactive”), but in my end-user mind I find it insane that though I’m currently using 7.1GB and have a total of 16GB, the OS should not be using 7.3GB of my hard drive. Use up the fast RAM first, then move the storage to the (albeit a fast SSD) slow disk. Don’t pre-emptively swap! Yes, I know this is a simplistic view and probably technically incorrect. But it’s annoying that OSX is using my hard drive when it doesn’t need to!

Restarting the Mac solves the immediate swapping issue, and my hard drive recovers the missing 7GB (in my current example, see screenshots below). But after about 3-4 days of uptime, the heavy swapping returns. Since this does not make any sense to me, I want to find the root cause. And I think I might have an inkling as to some of the swapping. Sorting the processes in Activity Monitor by virtual memory, I see that over time the socketfilterfw memory usage grows and grows and grows.

So my solution until Apple fixes their memory leak: every now and then manually disable and enable the firewall in System Preferences to immediately flush the bloated swap. 🙂

You can see in the screenshots below that I recovered > 7GB disk space used by the memory hog socketfilterfw by restarting the firewall.




I wonder what would happen if I left my machine on for an extended amount of time (talking many weeks here) without restarting? I bet socketfilterfw would eat up all the free space on my hard drive. Sounds like a challenge: maybe I’ll leave my machine on during my summer vacation and see what happens…

1 comment
  1. Update: uptime says 17 days.

    Current memory usage:
    9303 MB used
    7075 MB free
    Current swap usage:
    20480 MB total swap space
    19655 MB total in use

    socketfilterfw process using:
    Real Mem: 6.96 GB
    Virtual Mem: 15.09 GB

    I have been keeping track of the socketfilterfw virtual memory usage and it seems to increase about a gig per day. Nice.

    Restarted socketfilterfw.
    Current swap usage:
    20480 MB total swap space
    4047 MB total in use

    My coworker sitting next to me, who has his firewall disabled, has no virtual memory usage at all. Hmm… I need to talk to others here at the office to see if they have their firewall enabled and correspondingly crazy swap usage as well.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.