What Is the sleepimage File on Mac and Can You Delete It
sleepimage is the file at /private/var/vm/sleepimage where macOS keeps a copy of memory for sleep. Its job is to let the Mac restore your open work if power is lost while it sleeps. You can delete it with sudo, but with hibernation still on, macOS writes it again when the Mac next sleeps, so deleting it gives back no lasting space. Keeping it gone takes a power setting, and that setting removes the protection the file exists for.
What the file does
man pmset describes three values for hibernatemode:
hibernatemode |
What sleep does | If power is lost |
|---|---|---|
0 |
Memory stays powered, no copy on disk | Your session is lost |
3 |
Memory stays powered and a copy goes to disk, the manual's default for portables | The Mac restores from the copy |
25 |
A copy goes to disk and memory loses power: slower sleep and wake, better battery | The Mac always restores from the copy |
standby matters too. With it on, macOS moves a Mac that has slept for a while into hibernation, which also writes the image. That is why a desktop on hibernatemode 0 can still have the file.
Check your own settings and the file like this:
pmset -g | grep -E 'hibernate|standby|autopoweroff'
ls -lh /private/var/vm
The output names the path as hibernatefile. A folder listing can show /var/vm, which is the same place as /private/var/vm.
How big it gets
It is not always the size of your memory. The Apple silicon Mac this page was checked on has 48 GB of memory and a sleepimage of 2.0 GB, with hibernatemode 3. On your Mac the figure depends on the model and on what was in memory, so measure it rather than assume:
du -h /private/var/vm/sleepimage
That file has nothing to do with swap, even though the two have long been mentioned together. On a recent Mac, swap files live on a separate volume; how swap works on a Mac covers them. Storage settings usually count sleepimage inside System Data, so it can be part of a large System Data figure, though rarely the main part.
Should you delete it
For most people, no. A few gigabytes come back only until the next sleep, and the file is doing its job. If you really need that space on a small disk, the only lasting way is to turn off every setting that writes the image. The manual says hibernation images stop completely only when hibernatemode, standby and autopoweroff are all 0:
sudo pmset -a hibernatemode 0
sudo pmset -a standby 0
sudo pmset -a autopoweroff 0
sudo rm /private/var/vm/sleepimage
If pmset -g does not list autopoweroff, skip that line. The cost is that a battery running flat during sleep, or a desktop losing power, ends your session with no way back, so unsaved work is gone. To return to normal on a laptop, set hibernatemode back to 3 and standby back to 1, then let the Mac sleep once:
sudo pmset -a hibernatemode 3
sudo pmset -a standby 1
What not to do
- Do not delete the file again and again. It costs you the same writes, and the space comes back to the file at the next sleep.
- Do not point
hibernatefileat an external disk. The manual says it may only point to a file on the root volume. - Do not replace the file with a locked empty one, an old trick from forums. It fights a system setting and hides the real state from you.
- Do not disable these settings on a laptop that often runs out of battery. That is the exact case the file protects you from.
Where Mole fits
Mole has no Clean row for sleepimage: it is a live system file, and deleting it frees nothing for long. Analyze skips macOS system areas including /private, so /private/var/vm and sleepimage do not appear there and cannot be moved to the Trash from Mole. Mole does not change hibernatemode either. The only pmset setting it touches is disablesleep, which Keep Screen On uses to stay awake through a lid close. If your disk is full, the real candidates are usually elsewhere, and what to do when the startup disk is full is a better place to start.
FAQ
Can I delete sleepimage on Mac?
You can with sudo rm, but macOS writes it again at the next sleep while hibernation is on. To keep it gone, set hibernatemode, standby and autopoweroff to 0, and accept that power loss during sleep ends your session.
Why is sleepimage so large?
It holds a copy of memory for sleep, so it depends on your model and what was in memory. Check it with du -h /private/var/vm/sleepimage, since a figure from another Mac tells you little.
Is sleepimage the same as swap?
No. Swap holds memory pages while the Mac is awake and running short of memory. sleepimage exists for restoring after power loss during sleep.
What happens if I set hibernatemode to 0?
Sleep and wake may feel a little quicker and no image is written by that mode, but if power is lost while the Mac sleeps, your open work is not restored. On a Mac with standby on, an image can still be written until you turn that off too.
Does sleepimage matter on a Mac with a small disk?
It can, because a few gigabytes count more on a 256 GB disk. Even so, look at developer caches, iPhone backups and app data first, since those give back far more without changing how sleep works.