Memory information on MacOS X


Command line tools for diagnosing memory issues on Mac OS X. You can also use the Activity Monitor GUI program.

Installed memory:

# in bytes:
sysctl hw.memsize
# with a lot of other useful info:
hostinfo

Swap usage:

sysctl vm.swapusage

Usage of the different types of memory:

$ vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);'

Total memory in use (aka result set size):

ps -axm -orss= | awk '{ sum += $1 } END { print "Resident Set Size: " sum/1024 " MiB" }'

Memory usage by program:

ps -axm -orss,cputime,pid,command

source

Tags:  macos

Share: