On an Apple OS X system, you can determine the amount of memory in the system by clicking on the Apple icon at the upper, left-hand corner of the screen and selecting "About This Mac".
If you need to determine the amount of memory from a shell prompt,
you can use the sysctl
command.
$ sysctl -n hw.memsize 4294967296
The sysctl -n hw.memsize
command above shows my MacBook Pro
laptop running OS X 10.8.3 has 4 GB of memory (4294967296 bytes = 4 GB).
Another sysctl
option you could use is to query
hw.physmem
. But, be warned this will result in inaccurate results
on systems with more than 2 GB of memory.
E.g., checking the amount of physical memory with the command
sysctl -n hw.physmem
on my MacBook Pro with 4 GB of memory
results in the command telling me the system has 2 GB of memory rather than
4 GB.
$ sysctl -n hw.physmem 2147483648
If you wish to have the number displayed in GB rather than bytes, you can
use memsize.py,
which is a simple python script to convert the output of sysctl -n
hw.physmem
from bytes to gigabytes. You can run it from a shell
prompt by typing python memsize.py
.
$ python memsize.py 4 GB