6

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, 2015 at 17:49
  • @harrymc no, because that requires me to reboot, thus causing the memory / swap to be emptied.
    – karlingen
    Oct 29, 2015 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, 2015 at 12:43

3 Answers 3

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
  • 3
    no, because that requires me to reboot, thus causing the memory / swap to be emptied. –
    – karlingen
    Oct 31, 2015 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, 2015 at 20:32
1

OS X [macOS] pre-allocates up to 18 exabytes of swap space, though quite obviously doesn't use all that. In fact it grows & shrinks as necessary, all the time.

Any figure you see for Swap is only a 'recent high tide' marker. If you don't use it in 'some reasonable time' [exact figures unknown] then it will gradually shift that VM back to main RAM.

The management is quite complex - far above my pay-grade - but the best advice is to leave it alone to look after itself.

This has all become even more sophisticated in recent years, utilising the flexible boundaries of APFS so that VM now has its own partition.

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, 2015 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, 2015 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, 2015 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, 2015 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, 2015 at 8:57

You must log in to answer this question.

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