OS X Monitor Virtual Memory Usage from Command Line

By | 2011/11/11

OS X has a simple command line tool to monitor virtual memory usage: vm_stat.

I’ll show you how it works!



Crack open a terminal and run vm_stat. You will see an output somewhat like below:

$ vm_stat
Mach Virtual Memory Statistics: (page size of 4096 bytes)
Pages free:                          54492.
Pages active:                       541989.
Pages inactive:                     155818.
Pages speculative:                   57035.
Pages wired down:                   237289.
"Translation faults":             16011640.
Pages copy-on-write:                388318.
Pages zero filled:                10318325.
Pages reactivated:                     556.
Pageins:                            694134.
Pageouts:                              304.
Object cache: 13 hits of 64501 lookups (0% hit rate)


Another way to use vm_stat is to add a number 1 at the end, to indicate the seconds of polling time. This will let the memory usage continue to update on screen, every (x) seconds.

$ vm_stat 1
Mach Virtual Memory Statistics: (page size of 4096 bytes, cache hits 0%)
  free active   spec inactive   wire   faults     copy    0fill reactive  pageins  pageout
 53670 542464  57036   155687 237623 16024551   388519 10328143      556   694922      304 
 53824 542448  57036   155687 237623       27        0       26        0        0        0 
 53529 542415  57060   155688 237641       71        0       71        0        0        0 
 52678 542484  57036   155687 237624       82        0       82        0        0        0 
 52812 542507  57036   155687 237624       27        0       27        0        0        0 
 52955 542412  57036   155687 237715       27        0       27        0        0        0 
 53068 542461  57036   155687 237715       50        0       50        0        0        0

Cool!