Development Tips

Some usefull tricks for OSX People.

Show Free Memory on OSX

I was looking for Ubuntu’s free command for osx lion. I googled it as usual. I’ve seen that, there was a command called alloc and it is not available at the moment. I decided to write my own script in Ruby.

This is almost my first Ruby attempt! (I wrote in Python)

Based on “Activity Monitor.app” on OS X, used memory is a sum of:

  • Wired
  • Active
  • Inactive

memories. I managed to find out installed memory via sysctl -n hw.memsize. Here is the script that i wrote:

I embedded it to my prompt shell aka $PS1. I’ve checked and compared the results via htop and top commands. I get the same exac values. Due to OSX Lion, memory goes wild!!!. Especially Firefox leeches it abnormally. This little script kinda warns me that it is time to restart Firefox or close it for a while!

Comments