Minimum virtual memory (swapfile) size setting

Solution 1:

… set the minimum swapfile size …

dynamic_pager(8) Mac OS X Manual Page

With Terminal, a one-off command to convert a property list to a format that will be easily editable:

sudo plutil -convert xml1 com.apple.dynamic_pager.plist

Then if you're happy to edit with nano:

sudo nano /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist

Use option -S to set a size in bytes, then save that property list and either:

  • simply, safely, restart the Mac; or
  • unload then load the daemon – but that may be risky (and I suspect that only a restart of the Mac will reap the potential benefits).

That's a single size for all files, and any use of option -S will cause dynamic_pager to not use variable sized paging files:

  • we can not simply set a minimum – alone – amongst that set of variables.

… I want default allocate minimum 4GB …

Based on my tests with Mountain Lion, you might find that dynamic_pager will quietly fail to begin with a file that is so large.

Proceed with caution – pay attention to the actual size of swapfile0 and if it is zero bytes, then beware of inexplicable reductions to free space on the volume where the files are expected.

… at releasing will never release under 4GB size. …

Consider dynamic_pager option -L

If there are more than low-water-trigger bytes free in the external paging files, the kernel will coalese in-use pages and signal dynamic_pager to discard an external paging file. Low-water-trigger must be greater than high-water-trigger + filesize.