Mavericks' (and also Yosemite's) Activity Monitor shows a new diagram, the memory pressure. Sadly, its help text only vaguely explains what exactly it measures. How is memory pressure calculated?

Mavericks Activity Monitor - memory

Picture creds go to this answer from a poll question on Mavericks' best new feature.

up vote 51 down vote accepted

Memory pressure isn't a simple gauge of percentage of memory free and seems to be a 0 to 100% graph. The sysctl value of vm.memory_pressure is calculated in relation to a computed target that tracks the ratio between free and inactive memory pages to the wired and active pages. The absolute counters are viewed using the vm_stat command line tool to inspect detailed allocation of virtual memory. Jonathan Levin has excellent documentation at covering both macOS and iOS virtual memory and how they calculate memory pressure as well as the actions taken when the pressure index is high.

The relevant virtual memory (vm) that feed the calculation of vm.memory_pressure are:

  • vm.page_free_count - an absolute count of free pages
  • vm.vm_page_free_target - a calculated target or goal for a "pressure free" situation
  • vm.page_free_wanted - what the vm system would like to free to alleviate the current calculated pressure index

So - if you are tracking your memory pressure with Activity monitor (or my checking the sysctl values programmatically or at the command line shell) you would do well to look at these four values:

sysctl -a vm | egrep "page_free|pressure"

There is a new command memory_pressure introduced with Mavericks and when I run it to drive the memory subsystem into a warning state - you can see the memory pressure increase into a yellow range.

activity monitor results of <code>sudo memory_pressure -l warn</code>

The tool allocated about 4 GB of memory to the tool as the pressure graph increased steadily to this state where apparently the "warning" level is graphed: sudo memory_pressure -l warn. As you can see, the system before the pressure had 5.9 GB used and after was up to 7.99 GB used which doesn't even need to add up due to swapping and compression.

After watching how vm_stat 15 showed the warning result in no measurable paging, I quit the tool (Control-C) and then re-ran the tool to make memory pressure critical: sudo memory_pressure -l critical

I didn't let this run for more than a few minutes as paging was starting and once the tool said I had 5 GB of RAM paged to disk, I didn't want to fill my drive and quit the tool.

activity monitor results of <code>sudo memory_pressure -l critical</code>

You can observe how rapidly the system freed RAM after the warning was ended and also how it ramped into "red" territory to show that the virtual memory system couldn't compress enough pages to avoid swapping to disk. My educated guess is red on the pressure indicates swapping and dramatic over-allocation and/or a time where the free pages are below the amount the system prefers and it's actively purging inactive pages and/or swapping pages expected to be used to swap. Similarly, the system rapidly recovers once the allocations are released and pressure is taken off the virtual memory system.

  • Thank you for the clarification. I would like to know if there is a command (or set of commands) that calculate Virtual Memory, File Cache and App Memory parameters in the screen shot above. – Muhammad Hassan Nasr Mar 26 '14 at 13:33
  • @MuhammadHassan The answer below covers a nice reverse engineering summary of the algorithm and points out where to look in xnu open source for the internals. I've pulled out the 4 values covered that are most relevant to the GUI display of pressure. – bmike Aug 25 '16 at 11:02

To somewhat clarify and make that guess more accurate: memory pressure is a metric used by the kernel (xnu) with a dedicated thread called memory_status (previously known as Jetsam). This thread is responsible for detecting when the available RAM is low - which in OS X can force swapping, and in iOS kills the highest memory consuming app (as there is no swap). In Mavericks, the two OSes are closer together. Memorystatus issues a kernel note, which the Obj-C runtime eventually translates to an appDidReceiveLowMemoryWarning. Apps are supposed to purge unused or extraneous memory (for example, caches). Darwin's libC also purges memory automatically.

There is a specific (though undocumented) system call, vm_pressure_monitor (#296, if I remember correctly), which lets a client listen in on pressure events, and see how many physical pages can be reclaimed.

You can view pressure events on Mavericks using Process Explorer for OS X - downloadable from That both shows you the pressure "gauge", as well as pressure events.

  • That website also has a detailed article - - detailing Memory pressure and handling in OS X and iOS – user61711 Nov 5 '13 at 23:19
  • Awesome detail on the similarities and differences between Mavericks and iOS kernel. Thanks for the link to Process Explorer. – bmike Jan 3 '14 at 14:43

Memory pressure is defined by two counters Mach keeps internally:

  • vm_page_free_count: How many pages of RAM are presently free
  • vm_page_free_target: How many pages of RAM, at a minimum, should optimally be free.

You can see these easily using sysctl:

morpheus@Zephyr (~/Documents) % sysctl -a vm | grep page_free
vm.vm_page_free_target: 2000
vm.page_free_wanted: 0
vm.page_free_count: 73243

if the amount of free pages falls below the target amount - we have a pressure situation.


Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.