Apple - What I can delete from /private/var/vm?

/var/vm/sleepimage is used to store the contents of the RAM during hibernation, and the hybrid hibernation and sleep mode that Mac laptops use by default. If you have 8 GiB of RAM, /var/vm/sleepimage takes about 8 GiB of disk space. I don't know why it isn't deleted after waking up from sleep though. It might be to ensure that there is enough free disk space for it or so that it won't be stored on non-contiguous blocks if disk space is low.

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.

From man pmset:

hibernatemode = 0 (binary 0000) by default on supported desktops. The system will not back memory up to persistent storage. The system must wake from the contents of memory; the system will lose context on power loss. This is, historically, plain old sleep.

hibernatemode = 3 (binary 0011) by default on supported portables. The system will store a copy of memory to persistent storage (the disk), and will power memory during sleep. The system will wake from memory, unless a power loss forces it to restore from disk image.

hibernatemode = 25 (binary 0001 1001) is only settable via pmset. The system will store a copy of memory to persistent storage (the disk), and will remove power to memory. The system will restore from disk image. If you want "hibernation" - slower sleeps, slower wakes, and better battery life, you should use this setting.

  • 0 (traditional sleep mode) enables fast wake up and sleep, saves disk space, and reduces writing to the drive.
  • 3 (hybrid hibernation and safe sleep mode) enables fast wake up and sleep and enables restoring state after a power loss.
  • 25 (hibernation) saves energy and enables restoring state after a power loss.

I used hibernatemode 0 with my MacBook Air. Even if the MacBook Air went to sleep when the battery was nearly empty, the battery didn't usually drain out completely during sleep. /var/vm/sleepimage took about 4 GiB of disk space, and writing it hundreds or thousands of times might have reduced the lifespan of the SSD.


Addition: What Dan Barrett said about the sleepimage re-creation is true. However there's a way to get around it and therefore permanently free the disk space occupied by sleepimage.

The whole steps:

disable hibernation mode:

sudo pmset -a hibernatemode 0

delete /private/var/vm/sleepimage:

sudo rm /private/var/vm/sleepimage

create an empty file and name it 'sleepimage':

sudo touch /private/var/vm/sleepimage

change its flag to immutable:

sudo chflags schg /private/var/vm/sleepimage

In this way the system cannot re-create sleepimage anymore. This worked perfectly for me and I've not seen any problem on my Mac for 4 months.


Don't remove /private/var/vm it is your swap files which the OS constantly uses.

When you need less swap or you reboot the OS will reduce the number of files it uses here.