Under OS X Mavericks and below we just could launchctl unload the dynamic_pager plist, but trying to unload this plist doesn't have any effect since OS X Yosemite.

What is the new way to disable swap files now with OS X Yosemite?

  • Comments are not for extended discussion; this conversation has been moved to chat. – bmike Jul 13 '16 at 21:49

Have you tried something like this?

# Check installed RAM, disable VM if 8Gb or more.

mem_inst=`/usr/sbin/sysctl -n hw.memsize`

if [ "$mem_inst" -ge "8589934592" ]; then
    echo "8Gb+ Memory installed."
        if [ "$action" == "unload" ]; then
            sudo nvram boot-args="vm_compressor=2"
            sudo pmset -a hibernatemode 0
            echo "vm.compressor_mode set to 2"
            sudo nvram boot-args="vm_compressor=4"
            sudo pmset -a hibernatemode 3
            echo "vm.compressor_mode reset to defaults"
            launch_control $action /System/Library/LaunchDaemons com.apple.dynamic_pager
    echo "Less than 8Gb memory."

This isn't something I wrote, was information I found.

  • 5
    I just tried to use sudo nvram boot-args="vm_compressor=2", which might definitely be the correct solution, when looking at apple.stackexchange.com/q/118839/97060. I applied that command and rebooted. Will accept if there's still no swap in a few hours, just to verify ;-) (By the way, everything else in this post except that single command are useless commands...) – bwoebi Oct 29 '14 at 11:56
  • 1
    For followers, vm_compressor 2 is VM_PAGER_COMPRESSOR_NO_SWAP and 4 is VM_PAGER_COMPRESSOR_WITH_SWAP (ref: www.apple.stackexchange.com/q/118839/25085). On sierra I get nvram: Error setting variable - 'boot-args': (iokit/common) general error unless disabling system integrity protection first, then it works – rogerdpack Oct 26 '16 at 19:29

Here's what I do:

sudo pmset -a hibernatemode 0
(disables hibernation mode)

sudo rm -rf /private/var/vm/.
*(removes existing swap files)

sudo chflags uchg /private/var/vm/
(locks down the swapfile directory, prevents anything from being written to the folder)

As others have said, though, please only do this if you know what you're doing.

  • 1
    Which basically works too, but isn't the clean way. It just writes messages in the log files etc.. Just use sudo nvram boot-args="vm_compressor=2" and you're fine. – bwoebi Jan 13 '15 at 14:06
  • I should have said "Here's what I've done in the past" Between SSDs and a ton of RAM, I no longer choose to disable swap. It's more trouble than it's worth. – Patrick McMahon Jan 13 '15 at 14:08
  • According to wiki.summercode.com/… you should do some launchctl thing first? – rogerdpack Oct 26 '16 at 19:01
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist

Tested on freshly installed Yosemite from App Store.

  • 2
    Getting /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist: Could not find specified service . Also it doesn't have any effect on whether the system is swapping or not. (yes, I did reboot) – bwoebi Oct 27 '14 at 18:50
  • 1
    on sierra, requires you to "disable system integrity protection first" FWIW – rogerdpack Oct 26 '16 at 19:29

I used a program called Onyx to disable my swap file. & I have 16GB of RAM.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .