Background:
OSX keeps some information in RAM that is no longer used, but was recently used. This is called inactive memory, and is intended to improve user experience by speeding up some actions:
For example, if you've been using Mail and then quit it, the RAM that Mail was using is marked as Inactive memory. Inactive memory is available for use by another application, just like Free memory. However, if you open Mail before its Inactive memory is used by a different application, Mail will open quicker because its Inactive memory is converted to Active memory, instead of loading it from the slower drive.
Sounds questionable (just how much can you possibly speed up Mail on a quad-core machine?), but at least that couldn't possibly hurt since such memory can be treated like free memory! Actually, it can:
In OS X, when the number of pages in the free list dips below a computed threshold, the kernel reclaims physical pages for the free list by swapping inactive pages out of memory.
This makes me question whether OSX' memory handling is in fact superior; after all the same page mentions that
Paging of any kind... affects performance negatively because it forces the system to spend a lot of time reading and writing to disk. Reading a page in from the backing store takes a significant amount of time and is much slower than reading directly from RAM. If the system has to write a page to disk before it can read another page from disk, the performance impact is even worse.
Issue:
This (paging out inactive memory and the subsequent severe performance degradation) is likely to occur even during trivial tasks such as multi-tab browsing, even if the number of simultaneously open tabs is kept within reasonable (both Safari and Chrome appear to be guilty of adding to inactive memory whenever a tab is closed).
The machine becomes hardly usable when this happens - even opening up Terminal and purging memory can take a few minutes.
Question:
Can swapping inactive memory be turned off? Or, with inactive memory not being essential, can it be disabled completely?
Alternatively, is there a daemon or a preferably Apple app available that monitors inactive memory usage (an OSX oxymoron) and when it goes over an arbitrary amount (half a gig?) a purge is performed?