Mac OS X Mavericks freezes, stops responding when running out of memory

When the OS is starved for room on disk, bad things happen by design in an effort to try to keep the critical parts of the system online long enough to let a controlled crash happen and potentially let apps with changes to save survive until the cleanup activity starts.

Mavericks is much less likely to allocate the full amount of RAM to /var/db/sleepimage so people used to having that space preallocated can run into surprises when the OS needs a little room to grow the sleep image if operating conditions dictate.

The main tip would be to preserve several gigabytes of free space on the bootable volume when you have a workload that stresses the virtual memory system and runs with memory pressure in the red.

Here are my recommendations:

  • What scale or measure does Mavericks' and Yosemite's "memory pressure" adhere to? has some good information on monitoring and causing memory pressure on command
  • boot your system, log in one user, quit all applications
  • open activity monitor and observe / record the memory screen
  • put the machine to sleep and wake it 30 seconds later
  • run sudo du -sm /var/vm/* and note how large your sleep image file is as well as whether any swap files have been created on disk.

You will want to have ideally enough space on disk free to match your total memory footprint if you intend to run programs that take the virtual memory system into yellow territory for memory pressure. You probably won't need all that space for just the OS, but especially if you are getting mach memory errors like you are listing, the workload you are running needs a little more free space to grow than you are allowing.

Additionally, if you feel the system tuning is incorrect, you could easily file a bug report by running sysdiagnose after a clean boot as described above, once again when the system is running the intended workload properly and one last sydiagnose run once you've caused the memory allocations to start breaking the system. It's possible there are better choices Apple could have made, but it also could just be your software is buggy / leaking memory and the system is breaking as it was intended when the finite resources it has have become exhausted. Without more details it's hard to tell which is the case.


"shmem" is shared memory, and OS X is failing to allocate shared memory. It therefore seems the computer has run out of memory, both RAM and hard drive memory. Is this the case? At the time of freeze, there seemed to be about 1GB of space left.

  • Free up disk space by deleting files
  • Free up memory by closing applications

In this particular case, the logs later indicated that Spotlight had been trying to index a mounted sparsebundle volume, resulting in the backing disk running out of space.