Move swapped data to memory on a Mac?

4

0

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).

karlingen

Posted 2015-10-20T07:31:51.527

Reputation: 103

Does this link pertain to your OS X version?

– harrymc – 2015-10-28T17:49:12.060

@harrymc no, because that requires me to reboot, thus causing the memory / swap to be emptied. – karlingen – 2015-10-29T09:55:06.267

Why do you want to move this? BSD is quite liberal in using swap ( http://www.freebsd.org/doc/faq/misc.html#idp68642992) so I suppose OSX could be doing the same thing.

– HoD – 2015-11-02T12:43:09.067

Answers

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

harrymc

Posted 2015-10-20T07:31:51.527

Reputation: 306 093

2no, because that requires me to reboot, thus causing the memory / swap to be emptied. – – karlingen – 2015-10-31T20:01:01.413

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 – 2015-10-31T20:32:36.013

0

This page, says you can use:

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

franckfournier

Posted 2015-10-20T07:31:51.527

Reputation: 1

Hey, this is my link. – harrymc – 2015-10-28T18:46:22.340

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 ... – franckfournier – 2015-10-28T18:53:59.203

Franc, welcome to SU and bonjour. Just as a word of caution: examining existing comments and answers before hopping-in reduces friction. – harrymc – 2015-10-29T07:25:03.207

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 – franckfournier – 2015-10-29T08:49:18.353

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 – 2015-10-29T08:57:11.453