Is there a way to receive a warning if memory is running low?

You can acheive this with a combination of Growl and some shell scripting.

Growlnotify is a command line tool that can send a message to growl:

grownnotify -t "Title" -m "Message"

Wrapping some logic around this to check for CPU use or Memory use should be straightforward enough. I'm not at a Mac right now so can't test with commands but something like the following should be possible

while true
do
sleep 60
memuse=`vmstat -some -options -to -show -current -memory -use | awk '{ print $column_that you_are_interested_in_eg_5 }'`
if [[ $memuse -gt 80 ]]
then
growlnotify -t "Memory Low" -m "Memory use is at $memuse %"
fi
done

Thew above isn't going to work, please don't copy and paste it, but it's something to go on. You can expand the logic further easily by checking every 2 minutes, and if it's over 80% then check every 30 seconds to see if it's persistantly high and not just a spike, and if its still high after 3 checks then alert, otherwise don't etc.


If looks like @stuffe's answer does exactly what you ask, but if you don't want to get into scripting I have an alternative for you.

iStat Menus allows you to monitor many different system activities such as CPU Usage, hard drive space, network speed, temperature and memory usage. While it does not notify you, it stays up in your menu bar so you can tell when it's getting full just by a glance. You can also click on it and see what all is taking up the most memory:

enter image description here