My system (Yosemite / 10.10) has been paging out to swap memory despite my memory pressure reading less than 50% over the last 7 days (tracked with iStat Menus). How is this possible? It would be one thing if memory pressure exceeded 100% at some point in the last week and then the swap file was activated, but that doesn't seem to have happened at all and yet I've got 1.25 GB of 2.00 GB being swapped right now, with 36% memory pressure. Shouldn't the new memory model introduced in Mavericks behave differently?
-
1see if this helps - apple.stackexchange.com/questions/107126/…– TetsujinCommented Oct 31, 2014 at 9:05
-
Lots of good answers and details on this thread about memory pressure. I'd focus on optimizing for pressure and not swap allocation. 2 GB of swap comes quite easily from leaky code and as long as it doesn't impact your storage, why do the hard work to locate and find those leaks?– bmike ♦Commented Nov 21, 2017 at 22:14
1 Answer
This is one of the all-too-few times where the answer is officially documented by Apple.
The short answer is that the system tries to keep a certain amount of memory free so it can quickly provide memory to an application when the application requests it. When there is not enough free memory, then memory that has not been "touched" in a while gets swapped out. Often this is memory that the application "leaked", which is to say allocated, used for a while (maybe just once), and will never use again, but forgot to tell the OS it was done with.
In Yosemite and other versions of OS X, SystemUIServer was notorious for leaking lots of memory. This would be a prime candidate for getting swapped out, because it was not needed by the app, but could not be reclaimed by the OS. Swapping this memory out to disk is all upside for performance; the only downside is a relatively tiny amount of disk space used.