3

In Mountain Lion, I frequently used a simple automator app called "Purge Memory" which just ran "purge" in the command line. I really enjoyed cleaning the RAM, especially when buggy apps ran memory leaks.

But now in Mavericks purge requires root privileges, breaking my app. I know I can open terminal and input it, but that is not nearly as convenient.

I have heard that on Unix you can allow a specific command to always run as root. That way I could automate purge. I would like to know if anyone knows how to do this or if this would even solve the problem?

6
  • 5
    No. No no no no no. Running 'purge' to clear the inactive memory is bad. Very bad. Read here: apple.stackexchange.com/questions/67031/… Oct 23, 2013 at 9:50
  • When I open terminal and input "Purge"; the system replies: "Unable to purge disk buffers: Operation not permitted"; did this happen to you?
    – user60199
    Oct 23, 2013 at 16:14
  • Yes, you must run "sudo purge" in Mavericks.
    – JeffM
    Oct 23, 2013 at 17:54
  • 3
    As far as I'm concerned, running purge is a cargo cult. It's needed for the appearances only, it has no real benefits. You need it when you don't understand how the virtual memory system works on OS X. I have been running OS X since getting an iMac that had Leopard on it in Dec 2007. I've since been running various versions, and not once had I run purge. And I'm a heavy user, with three machines, and multiple virtual machines and lots of sometimes runaway code under development. The only thing purge is guaranteed to do is slow things down. Oct 23, 2013 at 17:58
  • 2
    @KubaOber: OS X (at least through 10.8) seems to handle inactive memory very poorly -- in theory, it speeds up operation, but in in my experience once you run out of free memory, it will start paging (rather than intelligently dropping inactive memory), and performance will fall off a cliff. purge does actually help with this. However, 10.9 has changed memory handling considerably, and until people have more experience with how it works, assuming purge will have the same effect it used to is unwarranted (although user60372's answer suggests it does still have the same problem). Oct 24, 2013 at 17:39

2 Answers 2

5

You could use a Run AppleScript action that runs do shell script "purge" with administrator privileges. It requires entering a password though.

If you don't want to enter a password, add %localaccounts ALL=NOPASSWD: /usr/sbin/purge to sudoers. (Run sudo visudo, press i, type or paste the text, press escape, and type :wq.) Then use a Run Shell Script action that runs sudo purge.

0
3

I disagree about purging unused RAM being useless. I have 8GB of RAM, and when free RAM gets down to a several MBs, my Mac gets very sluggish, and it's even hard to switch Finder windows without it being really slow. The purge command fixes that right up.

Now Mavericks uses compressed memory, so you aren't supposed to need such things, but I still find that my Mac gets unresponsive when there is not enough free RAM. Typing "sudo purge" into terminal freed up 2GB of RAM, and things are nice and snappy again.

1
  • Welcome to Ask Different! This is all helpful information, but doesn't actually answer the question regarding using Automator to invoke a purge. When you have 50 reputation, you can comment anywhere, and you should put information such as this in a comment.
    – grg
    Jan 3, 2014 at 21:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .