free -m alternative for Mac OS X
On Linux console it's easy to get free memory with free -m
. On Mac the utility is not directly available. The alternative is to fetch it from vm_stat
.
There's a great small Ruby script to do the job and display free memory in a simplistic form with a command free
in a following few steps:
- Download the free-memory.rb script (direct download link)
- Copy it to a folder on your Mac, e.g. to /Applications/Utilities
- Create an alias for a free command by editing the bash profile in Terminal:
nano ~/.bash_login
- At the end of the file, add
alias free='ruby /Applications/Utilities/free-memory.rb'
source ~/.bash_login
You're done. Type free
and you'll see something like 3.98G of 8.19G free
.