If you’ve used a tool like DaisyDisk to analyze your Mac’s disk space usage, you may have come across a file named ‘sleepimage’ that is rather large.
What is sleepimage in Mac OS X?
The ‘sleepimage’ file is just what it sounds like, it’s what your Mac had in it’s memory when the machine went to sleep, creating an image of your Mac’s previous memory state. When your Mac wakes from sleep, the content of sleepimage is read again and placed back into active memory, and your Mac is returned to the state that it was in prior to sleeping. Think of it like a swapfile of sorts, but for sleep and wake functionality only.
Why is sleepimage taking up so much space? 2GB, 4GB, 8GB, etc?
The sleepimage file is generally the exact same size as the amount of physical RAM your Mac has. If your Mac has 2GB of RAM, the sleepimage file will also be 2GB because there are 2GB of data that need to be stored when your Mac is put to sleep. You can check the size of your sleepimage file by typing the following command into the Terminal:
ls -lh /private/var/vm/sleepimage
You will then see data like:
-rw------T 1 root wheel 4.0G Oct 7 15:46 /private/var/vm/sleepimage
And the number between ‘wheel’ and the date is the sleepimage file size, in this case it is 4 GB.
There are cases where the sleepimage file is significantly larger than your physical RAM and this can be due to the file becoming corrupted.
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.
Where is sleepimage located?
If it wasn’t obvious from the previous commands, sleepimage is located alongside your Mac swapfiles at:
/private/var/vm/sleepimage
Hopefully that helps to explain sleepimage a bit and now you’ll understand what this mysteriously large file is on your Mac hard drive.