Using the Purge Command in OS X Yosemite & OS X Mavericks
Many Mac users running OS X Yosemite and 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 or newer. 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.
Running purge Command in OS X El Capitan, Yosemite, Mavericks
To use the purge command in modern versions of OS X, 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.
having problems again with sudo purge in el capitan start today
ok looks like it works on this install (11) of el capitan
I use this on 10.8.2 purge only
Works fine.
Now in El capi
NO
Last login: Fri Oct 30 03:12:17 on console
RAOSs-Mac-mini:~ raos$ purge
Unable to purge disk buffers: Operation not permitted
RAOSs-Mac-mini:~ raos$ purge
Unable to purge disk buffers: Operation not permitted
RAOSs-Mac-mini:~ raos$ purge
Unable to purge disk buffers: Operation not permitted
RAOSs-Mac-mini:~ raos$ sudo purge
WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type “man sudo” for more information.
To proceed, enter your password, or type Ctrl-C to abort.
Password:
Sorry, try again.
Password:
RAOSs-Mac-mini:~ raos$
-bash: : command not found
RAOSs-Mac-mini:~ raos$
sudo purge works fine in OS X El Capitan
Yes I can see thank you for correcting me I see you point.
I have 14GB of RAM used, I close all my apps, enter:
su
password
purge
My RAM is not freed up (by apps), only cache is.
Problem I have is that I need to reboot to reset the RAM usage to 3GB. I’d like to free up RAM for use in my AV software when I decide to set up a studio session, and not have to reboot before launching ProTools.
Any reason why the purge command isn’t freeing up that memory?
I’m running ElCapitan, w/ latest update.
You would need to quit apps that are using your RAM.
I’ve got same problem here…
purge will not working since el capitan
any one know why?
‘sudo purge’
works in El Capitan, easy.
There are a few tips for sudo purge. First, just because the Mac is friendly don’t get it in your head that you shouldn’t have to ever do something to you system. In fact, enjoy learning and using some OS X “power user” tricks. It makes the computing experience more personal. That said, know when sudo purge is a good idea and when it’s not. If you’re using CCC for example, it fills up all available memory to help speed up copying. Don’t purge while apps like CCC are in progress. If an app is using every bit of memory on purpose to perform a function don’t purge.
If you’ve got a bunch of flash based YouTube pages open in Safari, have photoshop open in the background and other apps open in the background with documents open and you need some extra memory but don’t want to quit apps, go ahead and purge memory. In this instance purging doesn’t interrupt anything. It just makes those apps go back to the hard drive or SSD for some data that was cached in RAM.
So that’s the key. If you’re going to interupt a program by purging, don’t do it. If not, do it all day long with no worries.
Safari with a bunch of YouTube tabs open is the biggest reason for the average person to purge. Don’t worry. Be a power user and go for it. sudo purge.
I never ran this command before. But the only time my Macbook Pro slows down is when I am running Handbrake on the High Profile preset and slower x264 setting, while playing the dvd movie, along with my usual 20 tabs opened on Safari including a few youtube videos, while compiling an adobe air-flex app, with Xcode running to edit my code, along with 5 terminal windows open, then VUDUToGo downloading movies in the background, and the Mechanical Clock 3D ticking away…
actually… the movie started to play slow because of hand braking while playing. But the system didn’t go slow at all…
I do not see why anyone is complaining about having to do this kind of work from terminal.
I am a Linux Sys Admin and terminal is my best friend. I purchased a Mac b/c it has the simplicity of a Windows system (as in installs and software available to it) with the security and flexibility of a Linux system (Mac is closely related to BSD after all).
I for one am ecstatic that there is a simple command to help free up resources.
Yosemite 10.10, 2014 Mac Mini 8Gb
Before Purge
Memory Used 7.9Gb
File Cache 2.78Gb
After Purge
Memory Used 5.54Gb
File Cache 326.9Mb
Apps open:
Terminal
iTunes
Fusion (VMWare/Windows XP)
Apple Mail
Safari
Preview
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.
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.
Actually, never mind that, what I just said is completely wrong.
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!!
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.
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.
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.
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.
Didn’t have to use purge once and I’ve been running Mavericks since beta 1. It fixed all problems I with unnecessary swapping.
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.
As you can see from the screenshot, the system has cleared all but 176 MB worth of file caches when needed.