I've tried these commands in OS X El Capitan, but it doesn't work:

$ sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist

$ sudo rm /private/var/vm/swapfile*

$ sysctl vm.swapusage
vm.swapusage: total = 2048.00M  used = 596.00M  free = 1452.00M  (encrypted)

I have 16GB of RAM and 256GB SSD, I just don't want the SSD to tear down faster just because I enable the swapfile.

  • I don't understand the last sentence - and if you have enough memory OSX won't swap - if tour swapfile is really 596 M then you need more memory to stop swapping
    – mmmmmm
    Apr 14 '16 at 14:54
  • @Mark What's the problem with swapping?
    – bot47
    Apr 14 '16 at 16:02
  • @Mark Actually, at this moment I have 7 of 16 GiB memory inactive, but still 1 GiB swap. This is perfectly normal and no problem at all.
    – bot47
    Apr 14 '16 at 16:04
  • 1
    @MaxRied the OP wants to stop swapping
    – mmmmmm
    Apr 14 '16 at 17:01
  • @Mark Unlimited amount of memory will not prevent it from swapping
    – bot47
    Apr 14 '16 at 17:03

El Capitan has its System Integrity Protection system, which you must disable before you can touch some OS inner workings, such as swap.

You'll need to reboot your Mac in Recovery Mode (holding Command+R at boot time). Open Terminal as root, then disable System Integrity with:

csrutil disable

Now you can disable swap.

After all done, you should enable System Integrity again using:

csrutil enable

You must log in to answer this question.

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