Skip to content

Instantly share code, notes, and snippets.

@aalexren
Created April 1, 2023 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aalexren/4dba2b850928077e41d3ee2840a15e5b to your computer and use it in GitHub Desktop.
Save aalexren/4dba2b850928077e41d3ee2840a15e5b to your computer and use it in GitHub Desktop.
Show utilization of RAM memory on macOS using vm_stat and top

To inspect RAM memory on macOS there are alternatives to vmstat or free on Linux: vm_stat and top (actually it's exists on both systems).

To check free RAM on macOS:
$> top -l 1 -s 0 | grep PhysMem
It will show you occupied physical memory and available once.

Either you can run this:
$> 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);'
It will show information in pages by default, but perl script provide output in human readable format.

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment