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.

« »