What is /private/var/vm/sleepimage, and can I delete it?

/private/var/vm/sleepimage and the swapfiles beside it are system files macOS uses to save memory for sleep and to handle memory overflow, and you should not delete them by hand.

Shiva ChandraMaker of Clean House · · 2 min read
Short answer

The sleepimage stores a copy of memory so a Mac can recover after power loss during sleep. Swapfiles hold memory overflow when apps need more RAM than the Mac has. macOS creates, resizes and removes both. Deleting them by hand can fail or cause trouble, so the verdict is Keep. Quit big apps and restart to shrink swap.

Path
/private/var/vm/sleepimage and /private/var/vm/swapfile*
What it is
System files for saving memory during sleep and for memory overflow (swap)
Typical size
The sleepimage can be as large as your Mac's memory; swap grows and shrinks with memory pressure
Made by
macOS
Safe to delete?
Keep macOS manages them. Do not delete by hand.
Comes back?
Yes. macOS recreates them as needed.

What are sleepimage and swapfiles?

The sleepimage is written when the Mac goes into a deeper sleep mode so that your session can be restored if the battery runs out. Swapfiles, named swapfile0, swapfile1 and so on, give the Mac extra working room when memory is full. The system keeps them in /private/var/vm, inside protected system storage.

You can look at them with a read-only command.

ls -lh /private/var/vm

Is it safe to delete the sleepimage or swapfiles?

No. They are managed by macOS, and the folder is protected. Removing them by hand is unsupported, can be blocked by system protections, and if it works can cause crashes or lost state for running apps. Do not use sudo rm on system paths. Apple does not document a way to turn this into free space by deleting the files.

How do I make them smaller?

  1. Save your work and quit memory-heavy apps such as video editors, virtual machines and many browser tabs.
  2. Restart the Mac. Swap files are cleared at restart.
  3. If swap keeps growing, open Activity Monitor and the Memory tab to see which app is using the most, and close or fix that app.
A Mac that swaps all the time is short on memory. The long-term fix is using fewer heavy apps at once, not deleting the swapfiles.

How Clean House handles it

Clean House shows the swap area as memory overflow made by macOS, with the call Keep, and says that it shrinks when you quit large apps or restart. System files are never offered for cleaning.

Questions

Can I delete the sleepimage file on a Mac?

No. macOS manages it, and the folder is protected. Do not remove it by hand.

Why is /private/var/vm so large?

The swapfiles grow when apps need more memory than the Mac has. Quit heavy apps and restart.

Will restarting reduce swap?

Yes. Swap files are reset at restart, and the Mac creates new ones only as needed.

Sources

  1. Apple Support: Free up storage space on Mac