Since I upgraded to Mac OS X Lion I’ve seen what I consider an abnormal rise in the App Store of micro utilities to recover memory.
Judging from some screenshots those small applications resides in the upper tray and if clicked will present a button that when pressed it start some procedure to gain back memory and make it available again for the operating system to use.
My late 2008 MacBook Pro has “only” 4GB of RAM and is suffering a lot in the memory department.
While it’s true that developing scalable web applications should not consume too many resources, all the hope is lost when you call your army of Virtual Machines to do your bidding.
I went for a fresh Lion setup and installed only a handful of applications specifically ready for Lion along with all the available updates.
Compared with the previous Snow Leopard setup, now happily living in an external disk thanks to SuperDuper!, Lion feels slow, and clearly, just by looking at the Activity Monitor, one of the bottlenecks here is the RAM.
I’m currently waiting for my 8GB upgrade and see if the situation improves (if it will work of course).
The reason for this post is that I noticed that every major app on my fresh install is taking up to 200MB+ or more, without even including the hungry and infamous the-more-I-have-the-more-I-want kernel_task, which does seem to raise a lot of confusion on official Apple forums.
I’ll illustrate in Lion how to achieve the same benefits that those applications provide, in a set-and-forget mode without spending a dime.
Using the technique below I noticed significant gains, you can verify them aswell by opening the Activity Monitor.app, right clicking the icon in the Dock and setting it to show the Memory.
Keep an eye on the green part of the pie chart when the script runs.
First, select the text editor of your choice, I personally use Textmate, and create a new file:
mate ~/Library/LaunchAgents/org.icoretech.purge.plist
For the bash novices the tilde (~) sign indicates your home directory, usually /Users/yourname
Copy/paste this code:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>org.icoretech.purge</string> <key>Program</key> <string>/usr/bin/purge</string> <key>StartInterval</key> <integer>3600</integer> </dict> </plist>
Save the file (CMD+S will suffice) and close the editor.
What we just did is to build a plist file that instructs our system to run the value of the Program key (/usr/bin/purge) every 3600 seconds.
Open up a Terminal and write this:
launchctl load -w ~/Library/LaunchAgents/org.icoretech.purge.plist
Now, this job will run every hour, you can tweak the number of seconds by changing the StartInterval integer number (in seconds) and it will free up your memory, you said it, for free.
To stop it:
launchctl unload -w ~/Library/LaunchAgents/org.icoretech.purge.plist
A downside of this is that the purge command will kinda freeze your mac for few seconds when it runs. It can be annoying at times.
$1.99 domains with SSL purchase!
Thanks, I’ll try this right now ;)
Not real clear. So do we create a file with the name of “mate ~/Library/LaunchAgents/org.icoretech.purge.plist” then paste the next bunch into the file and save the file WHERE? It doesn’t say anything about where to look for the file in the terminal command.
@Lon,
when you issue the mate command followed by the file path when you are in the editor just hit CMD+S and it will save the file.
The terminal command shows the file path just fine, the ~ character means your home directory, usually /Users/yourname
Are you nuts to use developer cmd every 3600 seconds ? Srsly? This is not for free..
I have not found any instability in my system during the use of this script, can’t see why it cannot be left run once a hour.
Thanks for tip, will try it out,
JFYI, I have a MacBook Pro (Intel core duo 2 – late 2009) with 8Gb of Ram and 500Gig HD, Lion still feels slow compared to Snow Leopard
Hi Julien,
I ordered the 8GB RAM sticks but they still has to be delivered, and I’m not quite sure they will work on my machine due to motherboard limitations; browsing around I’ve read that it should on my particular model, though someone said in a limited way. I have to try.
Indeed I’ve seen more recent machines choking at some point, where Snow Leopard literally fly compared to Lion.
Any luck with the 8GB ram?
Hey, thanks for the little command, however, terminal doesn’t recognise “lauchctl”! Any idea why?
I have a MacBook Pro mid- 2010 4GB Intel
It’s “launchctl”, make sure you write it correctly or just copy/paste the code :)
I also have a Late 2008 MacBook Pro with 4 GB and slow Lion. Could you please tell me if you succeeded installing the 8 GB? Because I thought the machine could not support more than 4 GB. Also Where did you buy it and what men did you buy?
Many Thanks!
Gonzalo
*men = mem (memory)
So I ran it. Terminal says that the plist loads but the inactive memory remains at the same level and doesn’t periodically decrease at the preset interval. What am I missing?
I just found the “purge” is no where to be found in the developer tools or the HD, even after reinstalling tools. Seems that it’s also pretty hard to find online. Suggestions?
Graci
I made the file, but when I kick it of…
launchctl: no plist was returned for: /Users/Theunis/Library/LaunchAgents/org.icoretech.purge.plist
Any ideas? Thanks!
This works! Thank you so much!!!
Actually, the solution provided here is very elegant but as the above comments show it is hard for novices. If you don’t mind doing the purging (i.e. cleaning up) manually when things are slow, then here is an easier way: (1) Run the Terminal program (under Applications/Utilities); (2) when the Terminal opens types “/usr/bin/purge” and hit return (no quotes). That will run the “purge” command.
How to monitor if you need to do this manually? One method is to run
the standard Activity Monitor program and check memory usage when things feel sluggish. I prefer to run a free program called iStat Pro which is a dashboard widget that continuously gives you a succinct update on your system; make sure you turn on memory monitoring. When Free memory is getting low (like in the 100′s of megabytes) run a purge. This works for me since I use the dashboard apps a fair amount for quick things (istatpro, dictionary, weather at a glance, etc.)
Again, thanks a bundle to the author (karin).
Separately, I was doing purge on Leopard years ago to make memory
issues go away. Then later versions of Leopard and then Snow Leopard
seemed to make the purge command do nothing (it would not freeze
up and just finish in a jiffy)… and of course memory was generally better.
Now with Lion it seems memory problems are back… Other people
can correlate?
this is the return path from the Terminal:
Last login: Tue Nov 1 16:18:14 on ttys000
host-003:~ cmodena$ launchctl load -W /Users/Library/LaunchAgents/org.icoretech.purge.plist
load: illegal option — W
usage: launchctl load [-wF] [-D ] paths…
host-003:~ cmodena$
Can you explain me where is the mistake? Thanks
Thank you, worked a treat for me :D
You can’t do that, purge is full clean memory (available for purge)!!!
And when you do “Purge”, all software (such iTunes is stop play) pausing :(
This works great on my macbook air mid-2011 running lion.
I use my MBA for development and runs VMs…really great to see the green color pie gets so big!
thanks!
I had to remove the script. The hiccup when purging is too irritating and additionally I bought 8Gb of RAM :)
I’m testing this out, so far so good. Here’s to terminal never exceeding 1 GB of ram used!
I tried it and terminal bounces back at me with this…..
aunchctl load -w ~/Library/LaunchAgents/org.icoretech.purge.plist
launchctl: no plist was returned for: /Users/rdtstarling/Library/LaunchAgents/org.icoretech.purge.plist
launchctl: no plist was returned for: /Users/rdstarling/Library/LaunchAgents/org.icoretech.purge.plist
nothing found to load
early 2009 mac book pro with 4gb ram and slow lion … :s I really like lion I wish it worked well….. anyways… did anybody succed in putting 8gb of ram on a mac book pro 2009 or earlier? I thought you couldn’t
g