Changing dynamic_pager settings under SL not working

One of the best performance tweaks I have learned is to increase the size of the swapfiles on OSX.

Instead of a collection of ever-larger 64M, 128M, 256M, etc. files, I typically change the dynamic_pager settings to make very large swap files in the hopes that I will need just one. (And this one file will be created at first-boot and I will not have to wait for the BeachBall while swap files are allocated/deleted at random points while I am trying to work.)

Historically, I simply add the argument "-S 1834100000" to create one ~1.8G swap file; that is usually all I need forever, especially with my 4GB MacBook. (The change is made in the com.apple.dynamic_pager.plist text file in /System/Library/LaunchDaemons.)

Under SnowLeopard, the file format changed for com.apple.dynamic_pager.plist, so you must use the Property List Editor to modify the file. (Really you have to make a copy, edit that, move the new one into place -- be sure to keep the original!)

Unfortunately, the dynamic_pager fails to work properly with with only the -S argument.

So I added high/low watermark settings of about ~100M and ~2G (-H 100000000 -L 2000000000), but this too seems to fail. The initial swapfile0 gets created and seems to work for some time, but later (perhaps after sleep and wakeup??) I start getting errors like this every 10 seconds as the dynamic_pager fails to start:

dynamic_pager: cannot create paging file /private/var/vm/swapfile0

Trial and error is just not yielding the answer I desire: how can one reliably change the settings for the dynamic_pager??

MacBook, Mac OS X (10.6)

Posted on Sep 9, 2009 8:21 AM

Reply
4 replies

Dec 2, 2009 8:20 AM in response to David Baker3

I experienced since some weeks constant problems "Your Mac OS X startup disk has no more space available for application memory." - even with more than 100 GB remaining on my 500 GB HDD that I had installed in my MBP. Console displayed the error: "(default pager): [KERNEL]: Swap File Error."

For some strange reason it seemed OS X was not able anymore to use the swapfile(s) at all. Even repairing disk permissions and removing previously existing /private/var/vm/swapfile0 e.g. using http://applejack.sourceforge.net/ didn't help.

Probably something went wrong with the Snow Leopard upgrade - I didn't use any custom /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist with Leopard so I wasn't expecting any problem from that direction.

Therefore, in case somebody else suffers from similar problem:
- Open a Terminal
- Type "sudo /Developer/Applications/Utilities/Property\ List\ Editor.app/Contents/MacOS/Property\ List\ Editor /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist"
- Inside the Property List Editor, expand the section "Program Arguments" and add the values David Baker3 suggested. Notice that for instance "-S" and "1634100000" must be two consecutive items of type string.
- Close the Property List Editor with saving changes.
- Reboot (might not be necessary, but doesn't harm).

This did the magic for me.

PS: Let's hope that either my situation was a very specific one or Apple will soon fix the cause of this problem. And for sure: manpage of dynamic_pager should reflect the requirements on which combination of values are valid - I also wasted some hours trying to find out, which combinations will work until I found David's helpful forum posting.

Dec 4, 2009 4:48 AM in response to JumpM

Unfornately, I not all problems have been resolved. After each reboot, the files in /private/var/vm still exist and Mac OS X cannot use them.

Console.app shows "dynamic_pager: cannot create paging file".

Workaround: Manually delete files in /private/var/vm, after that, dynamic_pager will be able to recreate files. Will send bug report to Apple.

Dec 4, 2009 6:56 AM in response to David Baker3

David Baker3 wrote:
Instead of a collection of ever-larger 64M, 128M, 256M, etc. files, I typically change the dynamic_pager settings to make very large swap files in the hopes that I will need just one. (And this one file will be created at first-boot and I will not have to wait for the BeachBall while swap files are allocated/deleted at random points while I am trying to work.)


I have grave doubts that this is really an effective performance tweak. In the first place, it should not take an appreciable amount of time to create a swapfile on a healthy HD -- if it takes long enough that you are getting beach ball wait cursors, something is wrong with your system and/or HD.

Besides that, forcing the creation of such a huge swapfile makes it quite likely it will be fragmented across several tracks on the HD, causing a performance decrease because of the large number of seeks that demands of the HD's head assembly just to access different parts of it. That is probably a major reason OS X creates small swap files at first & caps their maximum size even when many of them are required!

Related but more obvious is that creating such a large swapfile wastes a large amount of HD space that won't be used for anything. Some of this may be on the outer & therefore higher data rate tracks of the HD, meaning other files cannot use that space, resulting in another performance hit.

There are other things to consider, like the effect on the HD's internal buffers, but basically, the whole point of the dynamic VM system in OS X is to create swapfiles only as needed & to reuse their pages as much as possible to maximize performance. It is extremely unlikely that users can do a simple tweak that will improve on this.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Changing dynamic_pager settings under SL not working

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.