More virtual memory in Mac OS X

Virtual memory is the RAM that processes see when they're running, the memory space which the operating system allocates to them. The memory is called virtual because the addresses don't necessarily conform to physical memory addresses of the RAM hardware but instead the same address could refer to any number of possible physical addresses. It's up to the OS and the memory hardware to resolve the virtual address to a physical address, and do so transparently to each process.

Virtual memory can also refer to the data which was stored in physical memory but "paged out" to disk. The disk space which stores the "virtual memory" is called "swap".

OS X, like other Unix/Linux operating systems, uses virtual memory addressing and swap. In this way, processes (applications) are able to request more memory than is physically available, and the OS will pretend to have it (iOS is different from OS X in that addresses are virtual but memory can't be swapped out to disk). Swap in OS X is managed automatically rather than configured by an admin or user. So there is no swap partition or swap file to create in OS X. If you view swap size in Activity Monitor you'll see swap grow and shrink automatically. As swap size grows or shrinks, you can also see available disk space shrinks and grows in the same way.

You can't manually increase the size of virtual memory / swap in OS X.

Activity Monitor was updated since Mavericks to hide the paging statistics but it still shows wired memory, virtual memory size, swap used, and now it shows how much memory is actually compressed (meaning the memory takes less physical memory), and how much is being used to cache files, meaning that memory can easily become available if the files aren't needed before then. Memory compression is a newer feature of OS X.

If you feel your MacBook getting really sluggish while having lots of apps open or lots of tabs open in Chrome, you are probably thrashing. This means your apps are trying to access memory which is paged out to disk and the OS is trying to page them back in but there's no room so it is paging other processes out to disk, and so disk I/O is at maximum throughput and all those processes are blocked on disk writes to complete. The new Activity Monitor's Memory tab shows you this in the Memory Pressure time series graph at the bottom. Normally, it should be all green. When you're thrashing, you'll see the graph spike into yellow or red. This is bad.

Your computer can keep increasing swap but if you run out of physical disk space you can't grow swap anymore. At this point, you really need to start killing memory-hogging processes. You can reduce memory used by Chrome by opening its Task Manager, sorting tabs (tab groups) by memory usage, and killing them.

Add new comment