OS X swapping with free memory available?
I've noticed my machine keeps swapping memory even though there is (at this moment) around 7 GB of RAM still free; does anyone have any insights on why this is happening, if I should care, and if so, how I can stop it?
See this image:
Solution 1:
This looks 100% normal, fine and not at all even beginning to look like a problem.
Swap is for items that the system determines aren’t needed actively and frees up RAM for other tasks that can benefit. You have a very large proportion of free memory so the system is well in the green.
Apple’s activity monitor now has a “pressure” gauge so I would look at that and only worry if you see large page in / delays or yellow / red pressure on Apple’s graph.
To check page rates to and from swap, open a shell in terminal.app and run:
vm_stat 60
You will see counts per minute and the swap in and out are the ones to worry about. Next would be that you have a stable and low amount of free pages so that number going down to 0 or 10 would be worrisome about swap or allocations. Until then, you’re likely at full speed with any amount of swap that’s not filling your drive causing other issues.
Solution 2:
Does anyone have any insights on why this is happening
As officially documented by Apple, this is happening to keep a preferred portion/percentage of memory free and available for immediate allocation as processes request it.
if I should care,
No, you should not care, as long as performance is not suffering. The time to start caring about swap is when you experience long delays when switching between apps or when the entire systems slows down. When a system uses swap space to the point of thrashing, the resulting slowdown is not subtle, it is major and painfully obvious.
if so, how I can stop it?
The only practical steps to take are to add more RAM or run fewer applications at the same time, but until you are seeing significant slowdowns or getting error messages, it is not worth trying to stop the system from swapping memory to disk.