Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Swap files becoming a real problem. How to manage???

I have an 80 GB MacBook Air that is constantly filling up with swap files. I recently had to restart the machine to free up 32 GB of space. This doesn't seem normal. What steps can I take to make sure swap files aren't hogging up precious hard drive space? Am I really going to have to switch it off on a regular basis?

MacBook Air 1.6 GHz, Mac OS X (10.6.1)

Posted on Oct 14, 2009 2:00 PM

Reply
8 replies

Oct 19, 2009 7:01 PM in response to Allan Eckert

Sorry if I wasn't clear enough in my first post, but this is a MacBook Air. As you know, the MacBook Air comes with 2 GB of RAM, and it cannot be increased, and even if I replace the disk drive with a larger disk, that will only prolong the inevitable filling up of hard drive space with swap files.

The work that is being done is Entourage for mail and Safari for web browsing. That's it. I keep it to running only one application at a time. Never had a problem with these apps filling up swap files until after I "upgraded" to Snow Leopard.

I am seeing other people on the boards having the same issue. It would seem Snow Leopard has a problem with swap files.

Any other ideas?

Oct 20, 2009 2:41 AM in response to Brad DeMoss

I can confirm seeing similar behaviour using Apple Mail. Mind you, I was deleting around 6000 messages on a single delete-key-press (and so I was expecting some pain), but while "writing changes to disk" I watched /private/var/vm climb up to 18 swap files (using MenuMeters and keeping the memory menu open).

I am wondering if there are any new "larger" built in limits for NSUndo?

Oct 20, 2009 6:23 AM in response to Brad DeMoss

Brad DeMoss wrote:
I have an 80 GB MacBook Air that is constantly filling up with swap files. I recently had to restart the machine to free up 32 GB of space.


Are you actually seeing 32 GB of hard drive space used by swap files on the drive -- or just going by the "VM size" displayed in Activity Monitor? If the latter, don't worry about it. On my iMac with a total of 169 GB of its HD used, my "VM size" is a whopping 120 GB. Yet /private/var/vm contains only one swap file (swapfile0), using a mere 64 MB (binary base, reported as 67.1 MB in Snow Leopard's decimal based system) of HD space.

"VM size" isn't what you might think it is: it measures the total of how much memory address space is allocated to each process, not the total of how much real or virtual memory each is actually using. The OS creates swap files as needed to handle the necessary VM swaps, & swaps chunks (called pages) of any existing one with real memory without creating a new VM swapfile when it can. (It always creates at least one.) But it only creates new swap files when it must swap out more than it can from the existing ones. So from my swapfile size, I know that since startup the OS has never had to page out more than 64 MB at a time. If it did, it would create swapfile1, which probably would be 64 MB too: although I can't remember the details, the OS is programmed to create new swap files in some sequence like 64 MB, 64 MB, 128 MB, 256 MB, etc. -- whatever the VM designers decided would be the best compromise between efficiency & disk space use.

It is true that the swap files remain & continue to take up HD space until a restart, but they are relatively tiny, at least unless you are using apps that actually require massive amounts of paging to occur.

Oct 20, 2009 6:47 AM in response to .-scc__

FWIW, MenuMeters is a SystemUIServer plugin (also known as a Menu Extra). Apple does not support third party Menu Extras, which can destabilize the OS if not written carefully, so makers of things like MenuMeters rely on MenuCracker or its equivalent, which is basically a hack of the OS.

IOW, when you use MenuMeters, you are not using the OS supplied by Apple but instead a hacked variant that may or may not act like the Apple-supplied version. If you experience stability problems, especially after applying a system update, this is one of the first things to look for, since this kind of hack is often broken when Apple changes the OS.

Oct 21, 2009 3:24 PM in response to R C-R

A very good question. I should have been more specific.

I go into the vm folder and see the single sleepimage file that is the size of the computer's internal memory, followed by a series of swapfiles, which are named sequentially (swapfile0, swapfile1, etc.). They start out small, but double in size until you get to swapfile5, which is 1.07 GB (based on Snow Leopard's new method of calculating disk space). Then there are subsequent 1.07 GB swapfiles until the hard drive fills up.

So I am actually seeing multiple 1.07 GB swapfiles.

Oct 22, 2009 8:19 AM in response to Brad DeMoss

One possibility that occurs to me is that you have an application running that has a memory leak (or some other memory allocation bug). That is it keeps allocating chunks of memory and never frees memory when it is no longer needed. In this case running doesn;t require that you be actively doing something with it.

What happens if you let it run over night with without Safari or Entourage or any other App running.

Steve

Nov 21, 2009 2:59 PM in response to Steve Holton

Found it! Was lucky enough to be on the computer when the swap files started building up. In addition to filling up private/var/vm with 1 GB swap files, I noticed that the computer had slowed down considerably, so I ran activity monitor. Suddenly, java was using 40-50% of the CPU, but no apps were runnning. However, I did have a java-based background backup process running. To test, I shut down the process and uninstalled it. Voila! The 1 GB swap files began to disappear, and the computer's speed was back up.

Turns out the background process had a known issue with 64-bit java (hence why the issue didn't appear until after I upgraded to Snow Leopard). They have since released an update that fixes the problem.

Thanks for all the helpful suggestions! They pointed me in the right direction.

Swap files becoming a real problem. How to manage???

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