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)

  • I expect the "swapfiles" are for memory swapping, and the "sleepimage" is the saved state when the computer enters hibernation.
    – Tuesday
    Commented Mar 9, 2012 at 0:20
  • 1
    A very simple google search could answer this…
    – Alexander
    Commented Mar 9, 2012 at 5:03
  • 7
    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
    Commented Mar 24, 2012 at 22:23
  • Last comment ref @XAleXOwnZX
    – stuffe
    Commented Mar 24, 2012 at 22:34
  • @Alexander I did a simple google search and found this.
    – Sean Lynch
    Commented Aug 20, 2019 at 19:19

3 Answers 3


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.

EDIT You can delete /var/vm/sleepimage safely, but it will be recreated when you put the Mac to sleep. If you run sudo pmset -a hibernatemode 0; sudo rm /var/vm/sleepimage, the Mac will use a normal sleep mode (like desktop Macs by default) and it won't recreate /var/vm/sleepimage. See this post with more information.

  • 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
    Commented Mar 9, 2012 at 5:37
  • @NReilingh: I believe so, yes.
    – houbysoft
    Commented Mar 9, 2012 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.
    – Lri
    Commented Oct 16, 2012 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.

  • sleepimage is not part of the virtual memory system. sleepimage relates to power management and physical memory. Commented Apr 27, 2013 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


  • Can I safely delete sleepimage from my Mac?
  • Yes, you can remove sleepimage and it will just be created again automatically the next time your Mac is put to sleep. To delete sleepimage, type the following command into the Terminal:

    sudo rm /private/var/vm/sleepimage

You’ll be asked for the administrator password to gain access to remove the file, this is normal.

The sleepimage file is only needed for the safe-sleep function where your data is saved to the HDD before sleeping, if you want to permanently reclaim this disk space you can do so using the following commands in a terminal window. This will revert your computer to the older sleep method, which will sleep faster and wake faster but does keep your data in memory during the sleep period.

to check which mode is active

pmset -g | grep hibernatemode

to change mode 0= old style sleep 3= new (save to disk style)

sudo pmset -a hibernatemode 0
  • 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
    Commented Oct 15, 2012 at 19:14
  • I inlined the salient parts from the link.
    – Tetsujin
    Commented Feb 2, 2015 at 17:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .