Getting back inactive memory on Mac.


     OS X has the habit of keeping recently closed applications in memory so that if they are run again, they load quickly. The part of physical memory used for this purpose is called “Inactive memory”. The “System Memory” tab on the Activity Monitor application gives a break-down of the physical memory, including available free and inactive memory. Because of the way OS X behaves, you may or may not notice your system running low on “free” memory every now and then. This discovery could perplex you, because despite being low on free memory, you can load applications and go about doing your work. This is possible because inactive memory can be released by the OS X kernel’s memory management subsystem on demand. If it finds that the system is running short on free memory, and the user has started an application that is not already loaded in inactive memory, it will gladly comply and release enough of inactive memory to be able to run the requested application.

     I recently found a command line utility on OS X to release most of inactive memory. It is called, “purge”. The short description for “purge”, from its man page, states that its use forces the disk cache to be purged. The “disk cache” actually refers to “inactive memory”. To run this command, you have to type “purge” on Terminal.app (or any other Terminal application that you use). For example:

(Ayaz@mbp) [0] [~]
$ purge

     Before running the purge command, the memory breakdown on my system looked like:

     After the purge command ran, inactive memory went from 858MB down to 270MB.

     You will notice that the system becomes a little unresponsive while purge is flushing the disk cache. That’s fine and nothing to worry about.

     If you can’t find purge on your system, it could be because you have not installed XCode and accompanying development tools. These are available in one of the OS X installation discs. You can now also pay and download XCode from the Mac App Store.

     Have fun and be nice!

15 thoughts on “Getting back inactive memory on Mac.

  1. I don’t understand. If the inactive memory (which is, as you say, a cache) is automatically freed for new applications (ie, you don’t end up swapping because of it), why bother manually purging it?

    • Hi Faried. As a user, you won’t probably ever have a need to do it manually, unless you are overly obsessed with the amount of free memory on your system at all times (I’ve come across many a post on the web with people asking exactly how to do this).

  2. I found this useful. In my situation, I always run parallels to simulates windows(for my work) as well as a linux based server. After a while of use, my inactive memory increases to something like 4G (I’ve 8G in total installed on my MBP). While I have as little as 4x MB left, I realize that there is some pause whole I try to scroll down a web page( at this moment, I’ve closed all my applications. By that, I mean everything except the web browser). I have no idea whether the pause is caused by the time which is used for free the memory or something else. Anyway, I hope this would do the trick.

  3. My system will slowly grow inactive memory to consume all available ram. And yes, this should be reclaimed when it is needed but it just doesnt seem to work that way.

    When I ran purge just now it reclaimed 3.5gb. It also spent several minutes banging away on the disk as it wrote all that back out to swap.

    I suspect that when the inactive memory is reclaimed it often ends up causing a lot of disk io. If you are opening an app and a lot of data, and trying to write out a gig of inactive memory the disk is going to be really slow, and that is what I notice.

  4. I found that my Logitech SqueezeBox Music Server increases Inactive Memory when playing my songs from iTunes. Within 24 hours of playing time, Inactive Memory is using about 12GB of my 16GB of RAM. I am on Lion 10.7.2

    Doing a Permissions Repair will bring my Inactive Memory way down. Preferable to doing a Restart on my 3.4Ghz i7 (which also accomplishes this) as my computer is still functioning.

    I have had both Activity Monitor and Permissions Repair on simultaneously and discovered that the key repair was on HD/Library/com.apple.alf.plist. This has to do with my system Firewall but why this happens is unknown to me, I trashed this file and the computer regenerated it. I reset my Firewall but my Music Server still increases Inactive Memory. Oh well, another Permissions Repair brings it down again.

  5. This updates my 11/14/11 post:

    I found out why Inactive Memory (IM) keeps increasing. Every time a song is played for the first time (after a reboot or Permissions Repair), IM increases by the exact amount of the song’s size. If a song is 50MB, then IM increases by exactly 50MB. If a playlist is 587MB, then IM will increase by exactly 587MB.

    Problem is that IM never goes down – switching playlists, turning the device ‘off’ or changing to an internet radio station, will not wipe out the IM. Only a reboot, purge or Permissions Repair will wipe out IM

    The only time IM does not increase is when a playlist contains a song played in a previous playlist (makes sense – that’s what IM is for).

    I sent a full description of my findings to Logitech.

  6. Running this program is like turning out the light because your shadow is taking up too much space in your house. Hint: your shadow takes up no space and turning out the light will leave you in a worse state than before.

  7. I had downloaded Adobe Lightroom 4 trial (as a .dmg of course) and when it finished it said my system was low on storage… I have about 700gb free, so I checked available RAM and I had 4.05 of my total 8 gigs as inactive. So I ran purge (freed up almost all 4 gigs) and started the download over (because it automatically deleted the .dmg). Hopefully this works.

  8. Hey there! Thank you for the tip. I was getting a bit concerned of my Free RAM and regretting my decision of not upgrading the RAM to 16G. So ..thanks again :-)

  9. I drop a leave a response each time I like a post on a
    website or I have something to valuable to contribute to the conversation.
    It’s triggered by the passion displayed in the article I browsed. And after this article Getting back inactive memory on Mac. | Libel. I was moved enough to post a thought :-P I do have some questions for you if you tend not to mind. Is it only me or do some of the remarks come across like they are left by brain dead individuals? :-P And, if you are posting on additional sites, I’d like to keep up with everything
    fresh you have to post. Could you make a list
    all of your public pages like your linkedin profile,
    Facebook page or twitter feed?

Leave a comment