macOS – Reasons to Disable Swap File on MacBook Pro for Performance

macbook promacosperformancessdvirtual-memory

I came across a thread about installing an SSD drive in MacBook Pro.
Someone in the comments also recommended to disable the swap file but didn't say why:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
sudo rm /private/var/vm/swapfile*

I wonder why one would want to disable the swap file in Mac OS X.
Does it increase performance? Stability?
Any downsides?

Finally, does it make any sense to disable swap file when not using SSD?

Best Answer

wonder why one would want to disable the swap file in Mac OS X. Does it increase performance? Stability? Any downsides?

I suppose people would do it for an SSD drive because those drives don't have the same lifetime as standard magnetic spinning-disk drives. There are a more limited number of write cycles, so presumably using them with a swap file would use up these cycles more quickly.

Finally, does it make any sense to disable swap file when not using SSD?

If you have a lot of RAM, this would possibly speed up performance, but it's not a good idea in general. If you do run up against the memory ceiling, things are going to get flaky.

Also, wired memory isn't released when it becomes invalid, it is only released when a page out event is triggered, which won't happen if Virtual Memory is disabled. So it won't take long for all your memory to be gobbled up even if it is no longer used.