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

Should I delete swapfiles?

I have a 2011 Mac Mini with 2.3GHz Intel Core i5 processor and 8GB of memory. I have a 55GB Solid State SATA drive and an additional drive for storage. When I first turn my computer on, the Solid State drive shows roughly 2 GB of photos, 11 GB of apps, 20 GB of "other" and 22GB of free space. Within a half hour or running my computer, I get a Start Up Disk almost full notification and the "other" is typically around 40GB. This happens whether I run adobe software, or only open safari. I've determined there are sleepimages or swapfiles being created, but is there any way to stop this? Should there be 22GB of swapfiles on my system? I've read not to delete them...but I've also read they should only be as large as your memory on your computer - mine are nearly triple.

Mac mini, OS X Mavericks (10.9)

Posted on Feb 25, 2014 8:16 AM

Reply
Question marked as Best reply

Posted on Feb 25, 2014 8:24 AM

While you can delete the sleepimage file, it will simply be re-created the next time your machine sleeps. Sleepimage should be about the same size as the amount of RAM you have - it is the snapshot of your entire RAM image when the machine went to sleep (and is read from disk back into RAM when the device awakens).


Swap files will be whatever size is necessary - depending on the software you are using and the demand for memory. You should NOT delete them - you can cause many problems if you do so (there is no limit on how large SWAP can be - it will be whatever the load on the system requires it to be). The Virtual memory system is integral to OS X, and if Swap files exist, that means your system demand for memory has exceeded the available RAM and the system has no option (if you wish it to continue to run at all) but to move some of the memory load to disk. Swap files are purged though with a reboot, but if you are using the same software, at the same loads, they will just grow back again based on demand for memory.


If you consistantly are getting large swap files, then you need more RAM for the type of use you are putting the machine through.


P.S. according to OWC (http://eshop.macsales.com/shop/mac-mini/) a 2011 Mac Mini can support up to 16GB of RAM, so if you can upgrade yours, sounds like you should do so.

4 replies
Question marked as Best reply

Feb 25, 2014 8:24 AM in response to sledgerwood

While you can delete the sleepimage file, it will simply be re-created the next time your machine sleeps. Sleepimage should be about the same size as the amount of RAM you have - it is the snapshot of your entire RAM image when the machine went to sleep (and is read from disk back into RAM when the device awakens).


Swap files will be whatever size is necessary - depending on the software you are using and the demand for memory. You should NOT delete them - you can cause many problems if you do so (there is no limit on how large SWAP can be - it will be whatever the load on the system requires it to be). The Virtual memory system is integral to OS X, and if Swap files exist, that means your system demand for memory has exceeded the available RAM and the system has no option (if you wish it to continue to run at all) but to move some of the memory load to disk. Swap files are purged though with a reboot, but if you are using the same software, at the same loads, they will just grow back again based on demand for memory.


If you consistantly are getting large swap files, then you need more RAM for the type of use you are putting the machine through.


P.S. according to OWC (http://eshop.macsales.com/shop/mac-mini/) a 2011 Mac Mini can support up to 16GB of RAM, so if you can upgrade yours, sounds like you should do so.

Feb 25, 2014 9:08 AM in response to sledgerwood

Upgrading RAM would reduce or eliminate the system's need to create swap files. It does not disable virtual memory, but if the entire system memory load can be handled in actual RAM, then no swap files will actually be created.


My MacBook Pro (late 2008 unibody) has 8GB RAM, and for my use, I basically never actually have any swap files on my disk or in use - everything is running in RAM.


However, note that if you upgrade from say, 4GB to 16GB, your SleepImage file will grow to be 16GB as well. You cannot stop that unless you never allow your system to sleep/hybernate.


So in your case, you have two issues - too little RAM, and a very small boot drive in the 55GB SSD drive you use as your system drive. If you really want to improve things, you should upgrade both RAM and system drive. Maybe price a 128GB or 256GB SSD drive to replace that small boot drive you have now.


I saw that OWC lists a 120GB SSD drive that would work for about $100, or a 240GB for about $165.

Feb 25, 2014 12:25 PM in response to sledgerwood

There is excessive swapping of data between physical memory (that is, the memory chips on the logic board) and virtual memory (one or more files on the startup volume.) That activity is relatively slow and causes the whole system to be less responsive. It can happen for two reasons:

  • A long-running process with a memory leak (a kind of bug)
  • Not enough memory for your usage pattern

Tracking down a memory leak can be difficult, and it may come down to a process of elimination.


These instructions are for OS X 10.9 ("Mavericks.") The procedure may be slightly different for earlier versions of OS X.

When you notice the swap activity, open the Activity Monitor application and select All Processes from the View menu, if it's not already selected. Select the Memory tab. Click the heading of the Real Mem column in the process table twice to sort the table with the highest value at the top. If you don't see that column, select

View ▹ Columns ▹ Real Memory

from the menu bar.

If one process (excluding "kernel_task") is using much more memory than all the others, that could be an indication of a leak. A better indication would be a process that continually grabs more and more real memory over time without ever releasing it. Here is an example of how it's done.


The processes named "Safari Web Content" render web pages for Safari. They use a lot of memory and may leak if certain Safari extensions or third-party web plugins are installed. Consider them prime suspects.


Another process often implicated in memory leaks is "inkjet4" or "inkjet8," which is a component of the HP printing software. If it's present, force-quit the process in Activity Monitor to solve the problem temporarily. Empty the print queues in the Printers & Scanners preference pane (which has a slightly different name in each recent version of OS X.) If you don't use an HP printer, remove the software. Otherwise, if the problem is recurrent, update the software (which may not help) or contact HP support.

"Wired" memory should be a small part of the total. That memory is not swapped, but it makes less physical memory available which may then result in swapping. If you have a lot of wired memory, that's usually an indication of a memory leak in a third-party program that modifies the operating system at a low level. Ask for guidance in that case.


If you don't have an obvious memory leak, your options are to install more memory (if possible) or to run fewer programs simultaneously.

The next suggestion is only for users familiar with the shell. For a more precise, but potentially misleading, test, run the following command:

sudo leaks -nocontext -nostacks process | grep total

where process is the name of a process you suspect of leaking memory. Almost every process will leak some memory; the question is how much, and especially how much the leak increases with time. I can’t be more specific. See the leaks(1) man page and the Apple developer documentation for details.

Should I delete swapfiles?

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