I have a MacBook Pro at work and I think it uses too much swap instead of RAM.
Model Name: MacBook Pro
Model Identifier: MacBookPro13,1
Processor Name: Intel Core i5
Processor Speed: 2 GHz
Number of Processors: 1
Total Number of Cores: 2
L2 Cache (per Core): 256 KB
L3 Cache: 4 MB
Memory: 16 GB
Boot ROM Version: MBP131.0205.B22
SMC Version (system): 2.36f97
Serial Number (system): C02TL0KGGVC8
Hardware UUID: 09325653-7FB0-52CC-A599-063539D1010A
I am used to monitoring UNIX system activity using htop
. I notice that my OS X never uses more than half of the RAM, but uses more swap instead. Usually 7 GB of swap, but it can be more.
My question is, should not my OS use more RAM before swap ? I read about how OS X handles the swap and I feel like it is a loss of computational power. Writing pages in and out is really time consuming and is not as fast as using RAM
I try to compare with my Ubuntu 16.04 distribution at home which doesn't swap unless the memory is full. But maybe the 2 OS have different behaviors, though they are both UNIX based.
I also printed out the output of the vm_stat
command to check if there were any difference, because maybe htop
is not reporting it accurately. I noticed that htop
reports a varying maximum swap capacity, from 3 to 16. Why is it not a fixed size partition as in Ubuntu?
Mach Virtual Memory Statistics: (page size of 4096 bytes)
Pages free: 6743.
Pages active: 1005803.
Pages inactive: 903490.
Pages speculative: 361.
Pages throttled: 0.
Pages wired down: 837598.
Pages purgeable: 9241.
"Translation faults": 6115698117.
Pages copy-on-write: 107293117.
Pages zero filled: 2540298644.
Pages reactivated: 1039487337.
Pages purged: 52550607.
File-backed pages: 482299.
Anonymous pages: 1427355.
Pages stored in compressor: 5968822.
Pages occupied by compressor: 1439832.
Decompressions: 1456775259.
Compressions: 1606172332.
Pageins: 1393246141.
Pageouts: 25235109.
Swapins: 562867577.
Swapouts: 582845342.