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.

Is there a simple way to compact the /var/vm/swapfile0 etc, short of rebooting?

They can get quite large if things start swap'ing, and my laptop doesn't have much free disc space..

share|improve this question
1  
The only way to try to avoid swap space is to get more RAM or do your best to try and make sure your RAM usage stays as low as possible. (This snippet isn't worth it's own answer) –  Chealion Jul 19 '09 at 18:25
add comment

4 Answers

up vote 1 down vote accepted

As far as I know, the only way to force the /var/vm/swapfile* files to compact is (as you say) to reboot. I believe that more recent versions of OS X will compact these files automatically if enough memory is free and the system is idle. You could try closing some applications and waiting.

share|improve this answer
add comment

Mac OS X does remove swap files that it has dynamically created, if it no longer needs them.

I always find exiting/restarting Safari (or Firefox, if that's your browser of choice) tends to help...

share|improve this answer
add comment

Not really. Swap files are important system files and should not be modified by the user.

For more clarification, check out this article:

By default, Mac OS X uses 80mb fixed sized swap files. It'll create additional swap files as needed. This is controlled by the /etc/rc script file which is run during boot. You can see the part near the end where calls dynamic_pager. By fiddling with the parameters, you can hose your machine. Or you can change the default sizes. I did this on a PowerBook (Wallstreet) with a very small hard drive to have a finer granularity. Using 40mb swap file size, when consuming 90mb of swap, only 120mb of disk space would be dedicated instead of 160mb. Not a big change, and not worth doing for most people. You could have it create a much larger file too.

Mac OS X can actually do swap object re-location and swap file removal. This actually is a pretty cool improvement from the ever expanding swap file problem under NEXTSTEP/OPENSTEP.

share|improve this answer
    
The xlr8yourmac.com article dates from 2001 and more recent versions of OS X have different behaviour. dynamic_pager is now launched by launchd and its default behaviour is to allocate 64MB, 64MB, 128MB, (then doubling each time) files. –  Ben Lings Jul 19 '09 at 20:22
add comment

Mac OS X really comes under pressure when you have less and less disk space, which can cause issues. I would suggest backing some data up and removing it. Also check out the Caches in your Library folder to make sure your programs are cleaning up after themselves.

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.