5

I want to move the swapped content to my RAM. I currently have 6800/16384MB RAM and 241/1024MB of swap used.

In Linux one could execute this command to disable and enable the swap to force move the swapped content to the RAM:

swapoff -a && swapon -a

These commands are missing in OS X. How can I achieve the same behaviour? I am running OS X 10.11 (El Capitain).

3
  • Does this link pertain to your OS X version?
    – harrymc
    Oct 28 '15 at 17:49
  • @harrymc no, because that requires me to reboot, thus causing the memory / swap to be emptied.
    – karlingen
    Oct 29 '15 at 9:55
  • Why do you want to move this? BSD is quite liberal in using swap ( freebsd.org/doc/faq/misc.html#idp68642992) so I suppose OSX could be doing the same thing.
    – HoD
    Nov 2 '15 at 12:43
2

The article How to enable/disable swapping in Mac OS X says :

To disable swap (pager daemon) run this command in Terminal:

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

After stopping pager daemon, you may want to remove swapfiles by this command:

sudo rm /private/var/vm/swapfile*

To enable swap, you need to boot in Single Mode (Hold [CMD + S] at booting time) and run this command:

 sudo launchctl load /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
2
  • 2
    no, because that requires me to reboot, thus causing the memory / swap to be emptied. –
    – karlingen
    Oct 31 '15 at 20:01
  • If you have a computer that cannot be stopped, I suggest not to do such dangerous manipulations. In general, the swap space is always allocated as backup for the running application(s), just in case memory will become full. In fact, part of the launching of a program is first and always the allocation of swap space equal to the memory needed by the program. The swap space is never used if the operating system does not need more memory than is available in the computer. Since this is not your case, the swap stays allocated but unused, and is best left alone.
    – harrymc
    Oct 31 '15 at 20:32
0

This page, says you can use:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
6
  • Hey, this is my link.
    – harrymc
    Oct 28 '15 at 18:46
  • just googled "swappon on mac" and it gives you How to enable/disable swapping in Mac OS X - Home wiki.summercode.com/how_to_disable_or_enable_s... Traduire cette page How to enable/disable swapping in Mac OS X. To disable swap (pager daemon) run this command in Terminal: sudo launchctl unload -w ... Oct 28 '15 at 18:53
  • Franc, welcome to SU and bonjour. Just as a word of caution: examining existing comments and answers before hopping-in reduces friction.
    – harrymc
    Oct 29 '15 at 7:25
  • I apologies but there was no comments and no answers when i post my answer. But your post is better, i vote for it but it's not visible since i have not enough reputation Oct 29 '15 at 8:49
  • The comment was posted one hour before your answer. There is no problem on my side, just, as I said, a word of caution for the future. Don't feel bad about it and just keep on answering more posts.
    – harrymc
    Oct 29 '15 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.