Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I was using Disk Inventory X and found a file called sleepimage in /private/var/vm/ It takes up 4 GB! I also found numerous other files in the same folder called swapfile0 swapfile1, etc. What are they and are they safe to delete so I can free up space? (almost 10 GB)

share|improve this question
    
I expect the "swapfiles" are for memory swapping, and the "sleepimage" is the saved state when the computer enters hibernation. –  timothymh Mar 9 '12 at 0:20
    
A very simple google search could answer this… –  XAleXOwnZX Mar 9 '12 at 5:03
2  
It's not helpful to complain about a question that you find trivial via the medium of a comment that everyone else will also find trivial. I note there are no downvotes on the question, and that is the preferred method of providing such input. –  stuffe Mar 24 '12 at 22:23
    
Last comment ref @XAleXOwnZX –  stuffe Mar 24 '12 at 22:34

3 Answers 3

up vote 13 down vote accepted

swapfile0, swapfile1 and so on are swap files. You can sort of think of them like "backup" RAM. When your computer doesn't have enough RAM to accomodate the memory requests of all your programs (which is almost always, this is normal), it uses these files to "write out" part of what it had in RAM.

The sleepimage has a very similar use, except it's used only when your Mac hibernates/wakes up.

Deleting any of the swapfile* files is likely to mess up your system, but you can safely delete sleepimage. However, it's kind of pointless, it will probably be recreated the next time you put your computer to hibernation. If you really want to delete it, you'd have to use sudo rm, since root owns the file.

Finally, it's normal for the sleepimage to take up to 4 GB; it will usually take the same space as your RAM.

share|improve this answer
    
On Macs, a "hibernation" state is only ever used on laptops when the battery dies. I believe a typical system sleep will not write the contents of RAM to disk. (Can anyone confirm this?) –  NReilingh Mar 9 '12 at 5:37
    
@NReilingh: I believe so, yes. –  houbysoft Mar 9 '12 at 14:07
    
@NReilingh Laptops both keep the memory powered but also write its contents to the sleepimage by default. See man pmset and this question. –  ؘؘؘؘ Oct 16 '12 at 3:57

Those are part of the virtual memory system: swapfile* contains literally swap data, which is memory content that has been pushed out to disk.

The sleepimage is used for suspend and resume support; when the system hibernates, that is where the memory data is stored.

Deleting either would cause significant problems: sleepimage is the same size as RAM, and would need to be recreated to sleep; the swap files are memory that is in use, and would cause serious problems to delete.

If you use less swap, the system will automatically deallocate those files, though, and free that disk space.

share|improve this answer
    
sleepimage is not part of the virtual memory system. sleepimage relates to power management and physical memory. –  Graham Perrin Apr 27 '13 at 12:49

I just deleted my sleepimage and everything works fine, and to permanently prevent it from reappearing, follow the steps outlined in the comments of this article

share|improve this answer
    
Welcome to Ask Different! Please summarize the content of the article you are linking. The answer should be enough for solving the problem. Then you can provide additional information by using links. –  Maverik Oct 15 '12 at 19:14

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.