Is possible set the minimum swapfile size in OS X?

Currently OS X allocating swapfiles on demand, e.g. when when need 3.2GB will allocate 4GB and so on. But when the swap requirements start getting low the system deletes un-needed swap files. All these IO operations are very IO intensive.

Therefore looking for a way how to define the minimum swap file size, e.g. I want default allocate minimum 4GB virtual memory. When the system will need more than 4GB will allocate on demand, but at releasing will never release under 4GB size.

Is this possible somewhat? (using lion)


1 Answer 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.

You must log in to answer this question.

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