Quickly Check Mac OS X Virtual Memory Usage
Virtual memory serves a crucial task in modern operating systems, essentially how it works is that when you run out of real memory (RAM), the slower hard disk will take over as a temporary memory source. The downside is that the hard disk is slower, so running things in virtual memory is not ideal, one of the many reasons why more physical RAM is better. If you’re curious to see how your Mac is handling virtual memory though, you can see a quick overview from the command line with the help of the vm_stat command.
Checking Mac OS X virtual memory usage with vm_stat
vm_stat will spit out a generic overview of virtual memory usage, looking something like this:
Mach Virtual Memory Statistics: (page size of 4096 bytes)
Pages free: 5231.
Pages active: 130041.
Pages inactive: 73169.
Pages wired down: 53703.
"Translation faults": 84039105.
Pages copy-on-write: 7089068.
Pages zero filled: 32672437.
Pages reactivated: 432070.
Object cache: 1445817 hits of 1470191 lookups (98% hit rate)
If you want a continual update of your virtual memory usage, try adding a numeric value after the vm_stat command, indicating the amount of seconds that pass before refreshing the data. For example:
Now every three seconds you will get an update of virtual memory usage.
The man page for vm_stat is rather short, repeated here:
vm_stat displays Mach virtual memory statistics. If the optional
interval is specified, then vm_stat will display the statistics every
interval seconds. In this case, each line of output displays the change
in each statistic (an interval count of 1 displays the values per sec-second).
ond). However, the first line of output following each banner displays
the system-wide totals for each statistic. The following values are dis-displayed:
the total number of free pages in the system.
the total number of pages currently in use and pageable.
the total number of pages on the inactive list.
Pages wired down
the total number of pages wired down. That is, pages that cannot
be paged out.
the number of times the “vm_fault” routine has been called.
the number of faults that caused a page to be copied (generally
caused by copy-on-write faults).
Pages zero filled
the total number of pages that have been zero-filled on demand.
the total number of pages that have been moved from the inactive
list to the active list (reactivated).
the number of requests for pages from a pager (such as the inode
the number of pages that have been paged out.
You can also see some virtual memory usage information by using the top command, simply type ‘top’ in the Terminal to see an automatically updated live list of memory usage. Additionally, the graphical Activity Monitor in OS X will show how the Mac is handling virtual memory as found under the “Memory” tab.