Using the Purge Command in OS X Mavericks

Nov 14, 2013 - 11 Comments

purge command in Mac OS X

Many Mac users running OS X Mavericks have noticed the purge command, which forces memory cache to be emptied as if it a computer was rebooted, throws an error when attempting to run through Terminal in OS X 10.9. In most cases that error message is “Unable to purge disk buffers: Operation not permitted”. This does not indicate that purge no longer works in Mavericks, it simply requires super user privileges to execute properly in the latest versions of Mac OS X.

To use the purge command in OS X Mavericks, you must prefix the command with sudo in the Terminal like so:

sudo purge

Using sudo always requires the administrator password to be entered. Note there is no confirmation message that purge has run successfully, it simply takes a moment or two and returns the user back to the normal command prompt. Without sudo the “operation not permitted” error will remain, and though unverified, you may see other errors if command line tools have not been installed on the Mac in question.

The purge command remains somewhat controversial and best reserved for developers and fairly advanced users. Furthermore, the extent of purge’s efficacy with the newest versions of OS X remain debatable due to significant under-the-hood improvements to memory management with memory compression and improved cache handling, and further testing should be done to determine if there continues to be a benefit to using the command or whether it’s best to let OS X handle memory and caches entirely on it’s own. Nonetheless, some users may continue to find purge to be helpful in situations where free memory is running low, or when memory pressure is very high. If you are going to attempt to use purge under OS X Mavericks, you can watch the “Memory” tab in Activity Monitor to see the before and after results yourself, or use something more advanced like vm_stat from the command line to monitor virtual memory use. Purge dumps the virtual memory caches and frees up inactive memory.

Thanks to various commenters in our article about resolving unusual high CPU usage with Finder for the reminder about this, though purge is unlikely to have any impact on Finder performance it can be a helpful tool for other circumstances. Have an opinion on purge? Feel free to report your individual findings in the comments.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS X, Tips & Tricks

11 Comments

» Comments RSS Feed

  1. Cat flowers says:

    It shouldn’t matter with memory compression

    But theory is always different than practice, and OS X has always had weird inactive memory handling. Would rather drag system to a halt than free up useless caches in my experience.

  2. Peter says:

    Didn’t have to use purge once and I’ve been running Mavericks since beta 1. It fixed all problems I with unnecessary swapping.

  3. Dave says:

    in an ideal world, the fancy, shmancy memory management should make purge unnecessary. In the real world, some websites suck up memory like a kirby and some desktop apps as well. I find that playing video or streaming via Safari, some carbon copy cloner functions and a few other things victimize Mac OSX enough to warrant a purge. The difference is noticeable almost immediately after something has sucked up 8g or more of memory. Some apps will grab as much as it can get up to the max available and are not diligent about freeing the memory, leaving you with a very slow computer until you’re able to alleviate the problems.

    • Josh says:

      Agreed- I just used the sudo purge command and went from 5.5 GB of Ram being used to 2.2. My Activity Monitor provided no clue as to what program was using the memory, only that 5.5 was being used. Maybe one day we will live in an ideal world, but it seems that ‘not having to purge our own RAM once in a while’ day is not today.

  4. Minor gripe: you can set sudo to allow use with our password entry; either for specific commands, or for all use.

    It’s usually not a good idea, but it is possible.

  5. McMach says:

    With both photoshop cs6 and lighroom 4 running with the safari and mail open with minimum windows/tabs to aid learning photoshop, my 2011 iMac with 12 GB RAM becomes so slow … you have to wait with each slider adjustment … till I discovered (thanks osxdaily) the purge command. Immediately back to normal speed for at least another dozen or so photos.
    Had the activity monitor display memory usage as the dock icon and it was so useful…. when you see memory run out before the iMac slows down, issue a purge and all was well. Except in Mavericks, the option of using memory usage as the dock icon has disappeared. Now I have to open activity monitor and read the data instead of just glancing at the pie chart in the dock icon. Does anyone know how to bring that back? Thanks in advance.

  6. jojo says:

    I knew that Mac OS is the most advanced operating systems ever, everywhere in this world!!! I am so disappointed I must use Terminal, to get something the system should take care!!

  7. JGarrido says:

    I just ran purge on Mavericks, and the only thing it did was reduce the file cache. Swap, Virtual, and Compressed weren’t touched, and the system is still acting quite slow to respond, at the moment.

    • Pier says:

      You have to make sure to be using the “sudo purge” command and not just the “purge” command. The former frees up unused RAM, the latter operates on the cache.

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates