Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How would I prevent OS X even looking for a swap file?

I killed the swap file on my MBP. This is dead easy: just change the default swap file location so the system can't find it (goto /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist, change the last <string> in the ProgramArguments section.)

This achieves what I wanted it to achieve. My swap file is always 0mb and hence I can leave my mac on for weeks without the crippling swap-induced slowdown I came to loathe.

The question is, how can I stop the system looking for the swap file? The swap is never created because the path specified in the .plist file doesn't exist. But the system still looks for it, meaning a background process every 10 seconds, which looks like this:

dynamic_pager: cannot open swap directory /your/fake/directory/here
(com.apple.dynamic_pager[123]) Exited with exit code: 1
(com.apple.dynamic_pager) Throttling respawn: Will restart in 10 seconds

I want to stop this from happening, so my machine isn't constantly seeking something that isn't there, and to placate my innate OCD nature (as far as I can tell, this isn't using any real footprint).

Does anyone know how?!

share|improve this question
    
Why not find the app with the bad memory leak that's causing your swap problems and fix/replace/stop using it? Unix-based OSes and the software that runs on them have been designed around VM for so long, that running without it might be asking for weird problems. Software isn't used to the idea that malloc() could ever fail. Also, without a pager, I don't think memory-mapped file I/O would work. –  Spiff Mar 25 '11 at 4:46
1  
I've been doing this for a year, on and off. No bad side-effects to report, and I'm using my MBP ~10 hours per day, every day (I'm a designer). The point is not the apps, the point is OSX's swap managment is inherently broken. Running 8GB of RAM, before killing the swap process I rarely ever reached more than 4GB wired. Now I average 7GB... Give it a try yourself. –  Fred Stevens-Smith Mar 25 '11 at 9:38
    
And the advantage to having lots of "wired" memory rather than merely "active" memory is… ? Of course you're going to have more wired memory, since you've disabled Virtual Memory. –  ghoppe Mar 25 '11 at 18:32
add comment

3 Answers 3

If the .plist file does nothing else but call that program you can delete* it and/or unload it using

launchctl unload -w com.apple.dynamic_pager

*Move it somewhere else. Just in case.

share|improve this answer
add comment

According to http://www.willreese.com/?p=29 :

Disable:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
sudo rm /private/var/vm/swapfile*

Re-enable:

sudo launchctl load -wF /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist

However, to be clear, there is no "swap process" in OS X. These commands will disable and enable the pager process, which will increase the size of available swap. By disabling this process and restarting, you assure that the swap file size is always 0, effectively disabling swap on your system, since the system won't have any swap space available for use...

share|improve this answer
add comment

If you are interested in tweaking how the system handles swap-files you may look into hacking dynamicpager. This will basically keep a dynamic_pager process running, but it can be hacked to not use any swap, or only use a very small amount of swap.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.