iFreeMem 2.0: when you just don't feel like rebooting
As good as OS X memory management may be, if you run your system for long periods of time without shutting down you'll likely see an increasing number of spinning beach balls as your uptime counter ticks away. When applications quit – especially big, memory-hungry applications – they often leave your RAM fragmented and unavailable to subsequently launched apps. The solution is generally a reboot, but if you're looking for something a little friendlier and less time-consuming, iFreeMem is a superb solution. The utility was just updated to version 2.0 with full Leopard support.
I'm a long-time user of iFreeMem. On my MacBook Pro with 3 GB of RAM, it can generally clear up about 800 MB (sometimes more) after I quit a long session in apps like Photoshop and Motion. And it's rescued me on numerous occasions where I've found myself with three or four MB free and everything starts slowing to a crawl. I just loaded version 2 and it's faster and more efficient than ever. Good stuff.
The author has signed up with Trial-Pay, which I can't say improves the image of the app or increases my respect for it, but it does provide one option to get a $19 application for free. In light of the overall positive nature of this post, I won't delve into my opinions on Trial-Pay and its ilk. Suffice to say that I'm a happy customer of iFreeMem who paid full price and have never regretted it. Oh, and the 2.0 upgrade is free for users of previous versions, you just have to re-enter your registration code. You saved it, right?
Get a feel for whether or not iFreeMem would save some reboots for you with a 15-day, fully functioning trial.
Share
Categories
As good as OS X memory management may be, if you run your system for long periods of time without shutting down you'll likely see an...
Add a Comment
You want to reclaim memory? Open Terminal, type "top", hit return and then look at the used and free memory. Remember those numbers. Press and hold ctrl and hit c. That will end top and return you to the shell. Enter the following (without the quotes): "du -k ~/ >/dev/null" and press return and when the prompt returns, type "top", hit return and observe the current amount of used and free memory. You'll often see a sizable increase in free RAM.
February 22 2008 at 12:41 AM Report abuse Permalink rate up rate down ReplyBjorn is totally on the money.
You can use usr/bin/purge (type purge in the terminal) to flush the disk cache (inactive memory), or you can do many random reads from the hard disk to do the same thing.
The following is a shell script to do exactly what Bjorn describes (try with option '-h' for more details):
guns$ cat `which iopurge`
#!/bin/sh
# -- guns
#
# Purge inactive memory with rapid i/o
#
# 26 November 2007
# 'killall $command' is still printing to the terminal
# declare variables
before=
after=
memPurged=
pageSize=
pagesPurged=
timeout=5 # in seconds
command="du /"
showUsage="Usage: $(basename $0) [-h] [-t seconds] [-c "command"]"
function printError()
{
echo >&2 $showUsage
echo >&2
echo >&2 "See '$(basename $0) -h' for more details."
}
function printHelp()
{
echo "Purge inactive memory with rapid i/o."
echo
echo $showUsage
echo
echo "Supported Options"
echo "-----------------"
echo "-t{seconds}tSet the amount of time for the command to run. Default"
echo "ttis 5 seconds."
echo "-c{"command"}tSet the command to run. Default is 'du /'"
echo "-httDisplay this help and exit"
}
function getMemFree()
{
# the "$3-0" bit is a dirty way to chop the period at the end
vm_stat | awk '/Pages free/ {intMemFree=$3-0; print intMemFree}'
}
function getPageSize()
{
vm_stat | awk '/page size/ {print $8}'
}
# variables in: $timeout and $command
function purgeMem()
{
# print a message
printf "Accessing disk"
$command >/dev/null 2>&1 &
# give some feedback
for (( i = 0; i < $timeout*2; i++ )); do # Display a dot every half
sleep .5 # second, so multiply $timeout
printf . # by two
done
# kill the process; if exited early, this will be a zombie process
killall $command >/dev/null 2>&1 &
if [[ $? == 0 ]]; then
echo "stop"
else
echo "runaway process!"
exit 20
fi
}
#
# Main
#
while getopts ":ht:c:" option; do
case $option in
h ) printHelp; exit;;
t ) timeout=$OPTARG;;
c ) command=$OPTARG;;
?) echo >&2 "Invalid option!n"; printError; exit 3
esac
done
shift $(($OPTIND-1))
before=$(getMemFree)
purgeMem
# set variables
after=$(getMemFree)
let pagesPurged=$after-$before
pageSize=$(getPageSize)
# calculate and print
let memPurged=($pagesPurged * $pageSize / 2**20)
printf "%d MB purged.n" $memPurged
Another free version for leopard is to type 'a' into spotlight and make sure you delete the 'a' just before you start paging. The mds process ends up using lots of memory, and when quit it you end up with lots of free memory :)
February 21 2008 at 7:29 PM Report abuse Permalink rate up rate down ReplyI've had my Mac running for months on end without any of these memory problems.
February 21 2008 at 6:34 PM Report abuse Permalink rate up rate down ReplyMark Russinovich's great article from a 5 years back went into great details why these things are genuine snake oil even for the PC, let alone Darwin:
http://www.windowsitpro.com/articles/index.cfm?articleid=41095&cpage=97
free reprint: http://license.icopyright.net/user/viewFreeUse.act?fuid=NzgyNzU0
However, just like homeopathy, placebo is powerful medicine, and if it works to make you feel better, let the placebo rule!
There is definitely something that causes my Macs to slow to a crawl after a few days uptime, and kernel_task's memory allocation to approach infinity. I'm going to test iFreeMem along with the weekly script to see if either has any real effect.
February 21 2008 at 4:06 PM Report abuse Permalink rate up rate down ReplyIf your system is constantly being bagged everytime you launch another app, then spend your money on RAM not cheezy apps like this.
February 21 2008 at 4:05 PM Report abuse Permalink rate up rate down ReplyI'd take a wild guess that this app does something not dissimilar the following:
void
free_up_memory()
{
int c;
char *p, *q;
for(c = 0; c < 2048; c++)
{
if(!(p = malloc(1024 * 1024)))
{
return;
}
for(q = p; q < p + (1024 * 1024); q += 4096)
{
*q = 1;
}
}
}
â¦in other words, it allocates as much memory as it can and makes sure it gets "dirty", forcing everything else to get swapped out. Then it frees it all up again.
The effect is that all your latent caches for applications you're not actually running any more get thrown away, but also all of the memory used by applications which *are* running get swapped out to disk and needs to be pulled back in again.
Really, Darwin's VM could do with a doing a better job of releasing now-unused blocks of virtual memory and gradually swapping things back in which are still running but have been swapped out to make room for the now-dead stuffâI often find it can take a while before the actual amount of âfreeâ memory I have matches what it really should be, and have chunks of VM swapped out that would be more useful swapped back in. In real terms, though, it's a minor quibble, and unlikely to be one that's worth $19 unless you have some sort of psychosomatic condition triggered by Activity Monitor's pie charts.
Ah, so the memory "recovery" programs have run out of gullible Windows users to sell their products to and they've moved on to gullible Mac users.
I say this with love. I used to use one of these on Windows as well, before I realized it did nothing, other than sometimes crash my computer.
Radek: That is within-application memory fragmentation. Memory in MacOS (and other modem desktop/server OSs) is allocated in pages (typically of 4KB each). On a machine under fairly heavy use, many of those pages are temporarily stored on disk (swap space, aka. scratch space). When your app has allocated lots of those pages, but only touches a few bytes in each page, the OS may end up writing to/reading from swap much more than necessary. That's what your linked page is about.
However, when the app quits, all pages are returned to the system.
Brett: It is true that in somewhat uncommon circumstances you gain some responsiveness by proactively reclaiming pages. It sounds like you have reliably identified circumstances where it helps you. However, you don't need to buy an app to achieve that. And more often than not, it decreases responsiveness. (Did you also run "sudo periodic weekly" also, or just the "daily" variant?)
Manually, just the daily variant. I'll run both and see what results I can get. If it can do what this app does, I'll happily hand my license off to someone less convinced that all these computer engineers know what they're talking about :).
February 21 2008 at 12:47 PM Report abuse Permalink rate up rate down ReplyHot Apps on TUAW
Deals of the Day
more deals- Verizon Leather Sleeve for Tablets for $4 + free shipping
- Wicked Jaw Breaker Noise-Isolating In-Ear Headphones for $6 + free shipping
- Refurb Apple MacBook Air Laptops: 12" 64GB SSD for $699 + free shipping
- JVC Motion Sensing Clock Radio with Dual iPod Docks for $55 + free shipping
- Apple iPhone Headset with Mic for $4 + $2 s&h
- Refurb Apple iPod nano 8GB MP3 Player for $99 + free shipping, 16GB for $119
Software Updates
more updates- EFI Firmware Update brings Lion Internet Recovery to 2010-model Macs
- OS X Lion 10.7.3 released with Safari 5.1.3, Wi-Fi bug fix
- Aperture updated to 3.2.2, addresses Photo Stream issue
- Apple updates Keynote to address Lion issues
- Google Search app gets new look on iPad
- Apple releases Apple TV Software Update 4.4.3



24 Comments