We recently wrote an article telling you all about what exactly virtual memory was in the context of OS X, what it does, and how you can check how much of it you’re using (using the Activity Monitor, as pictured below). If you can’t be bothered to read the article, shame on you, but to sum it up, while virtual memory can be a very useful to push your RAM to it’s limits, it can also slow down your computer significantly, and many want to know how to disable it.
Here’s how, but it’s not exactly the easiest thing to do and you risk messing up your computer. We hold no responsibility if you mess up your Mac as a result of following this.
1. Open Terminal (Found In Applications > Utilities)
2. Virtual memory on the Mac is controlled by a swap file, and that’s what you’ll need to deactivate. Type this command into the Terminal:
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
3. If you want to completely delete the files (really don’t recommend it, as you will never be able to modify virtual memory again), then type this command:
sudo rm /private/var/vm/swapfile*
If you’ve only gone as far as step two and want to reactivate the swap file, type this then close the Terminal:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
I’ll stress again that this is risky stuff, so if you don’t know what you’re doing, don’t try it. Instead, there are some much easier solutions to improving memory performance.
Upgrading the RAM itself is the most obvious one, and you can also run fewer programs at once and create more space on your hard drive. Disabling virtual memory is only something you should do if you have a specific purpose in mind, nothing else.