What the hell is Virtual Memory? For Linux aficionado, it is the SWAP space. In simpler words Virtual Memory acts like RAM, but it uses HDD as the space instead of a unit of physical RAM chip. The benefit of having SWAP active on your machine is it can boost performance when you’re lacking RAM capacity as in you need to run few applications that need more than 4.5 GB RAM but you only have 4 GB RAM, hence the 0.5 GB will be moved to SWAP. That’s simplest way to explain, and maybe technically inaccurate.
@pali7x recommended me to turn of the encryption on the VM because it can boost up performance a bit. So, I give a go. Simply fire up the Terminal with this command line
sudo defaults write /Library/Preferences/com.apple.virtualMemory DisableEncryptedSwap -boolean yes
If you want to revert back to normal, simply change yes to no. The command line above disables the encryption on you SWAP space. If you want to check, you can use this command:
If you haven’t turned off the encryption on SWAP, it would return like this:
vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)
And if you just turned off the encryption, it will be like this:
vm.swapusage: total = 64.00M used = 0.00M free = 64.00M
That’s it. Encryption is turned off. If you wanna be a bit radical (and you have RAM more 8GB or more), maybe you might want to fully disable SWAP space. It can be done by simply firing up your Terminal with this command:
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
Warning! Please do research about turning off Virtual Memory.
… and why do I need to disable the encryption on VM?
Using HDD as the SWAP as the extension of RAM is a good idea, but the downside is the read/write speed on HDD is much slower than read/write speed on RAM. On OS X, encryption is forced on the SWAP space, adding the ‘insignificant lagginess’ in bargain for extra security. Normal end user won’t notice this, but for experienced user, you can really feel it (as the matter of fact, I do).
So, to reduce the ‘insignificant lagginess’ effect, I turned off the encryption. Turning the VM completely might minimize the lagginess even more, but I’m not gonna recommend it if you have RAM less than 8GB.
p/s: Please restart your OS X for the change(s) to take effect.