sleepimage – the Mac OS X sleepimage file explained
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.
I decided “2” delete my sleepImage and now my computer will Not start.
unable to delete swapfile same directory as the sleep image on Mac am running Mac OS high Sierra 10.13.5 ,iMac 3.4ghz witht 8 gb of ram ok thanks
I have a problem.
I switch on my MacAir OS 10.6.8 and after about 10 minutes—without me touching anything at all—there’s no empty space left. Swapfiles have been created and filled the 8Gb that was available on the 60Gb SSD.
So: I opened Activity Monitor. After a few minutes it became clear that iCal Helper had the biggest Real Memory and soon after that its Virtual Memory that had started at less than 236 Kb was growing in Gigas; ending up consuming all the available SSD space, about 8 Gb. Its Real Memory also grew, from about 330 Kb up to nearly 800Mb.
What to do?
Should I trash iCal?
Trash iCal Helper? (using Onyx I can see invisible files, but haven’t found iCal Helper)
What can I do?
[…] hibernation function, known as SafeSleep. Essentially, hibernation dumps the contents of RAM to a sleepimage file on the hard disk when a Mac is put to sleep or runs out of battery. That hibernation file is […]
[…] the battery. Basically, standby (and sleep) works by dumping everything out of active RAM into a sleep image file on the hard drive, and then when the Mac wakes from sleep that sleep image file is copied back from […]
17GB sleepimage… for 16GB RAM… okay…
It should be 16GB for 16GB of RAM, how did you determine the file size? Enter the command “ls -lh” in that directory to get the file size.
Wonder why the image has to be the minimum size of your ram. Would be cool if it could be only the size of active RAM.
Thx for the informative article and tips in the comments!
Be sure to read “man pmset” for the hibernatemode options. only use 0,3,25 or suffer the consequences.
I can’t believe that this feature filled up the entire HD on my Mac Mini and didn’t notice that it was causing the ‘full disk warning’. Eventually I couldn’t even boot, so I had to use Target Disk mode to search and rm the files causing this…. now I’ve switched to mode 0 on hibernatemode. There were some other files created by the timemachine program, some kind of image file. I purged them too and will turn off that ‘instant’ feature of time machine.
FYI, 12 gb RAM takes about 20 sec to wake up on my 3.06 GHz core i3 desktop
16 Gb. I have 16 GB of ram.
Can this cause any problems in the long run? If I close the lid will it just shut off?
[…] fixing this by repairing permissions in the hope that some file responsible for sleep (such as my sleepimage file) had problematic permissions set. Alas, that didn’t work so I continued my search. I […]
From man pmset:
Please note that hibernatefile may only point to a file located on the root volume.
[…] I didn’t need this and I needed all the space I could get from my new drive. So I used this article to find and delete the […]
[…] 1 next to it indicates that feature is enabled, a 0 is disabled. The ‘hibernatefile’ or sleepimage is where the contents of your Mac are kept when you sleep the machine, this serves as a cache file […]
I can think of a good thing with this method. Close your macbook pro and it will be put to sleep, and then take out the battery so it will shut off perm. Reattach the battery, and then reboot the mac, the mac will resume to where you left off because of the sleepimage in your hd. Its like… hibernation , but better.
Personally i perfer to disable it because i have a 5400rpm hd and 4 gigs of ram, and it takes like 10 seconds for the machine to fell asleep…
Just guessing, but looks like there is a setting “hebernatefile”:
pmset -a hibernatefile /path/to/sleepimage
Wow.Great..thank’s a lot..now i’m understand
You failed to mention the difference between ‘sleep’ and ‘safe sleep’, and this might confuse some.
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
==============================
to remove sleep disk image
cd /var/vm
sudo pmset -a hibernatemode 0
==============================
correction to the last part of my message…
to remove sleep disk image
rm /var/vm/sleepimage
copy&pasting only works right after the morning coffee :)
are there negatives to doing the old method (in where the new method was created)
is there a way to change where the sleep image is stored? I have two internal storage devices and want the sleep image off of my SSD and on my HDD.
I’m currently running the OS on a smaller SSD via express card slot and still have my bigger HDD in my Late 08 unibodyMBP and could use all the space I can get. The sleep image is currently 6GB reflecting the RAM as the article says.
I would think that the only negative is that battery life while asleep would be diminished, as it is actively keeping the RAM contents in RAM as opposed to the disk. Also, if youre laptop dies while asleep, youll lose all your data. I tried changing it, and didnt really notice a difference, it seemed to wake slightly slower though.
Hi JB.
I grepped mine and it’s in “hibernatemode 0” yet I still get 17GB of SSD occupied by that image file, as I have 16GB of RAM.
Isn’t hibernatemode=0 supposed not to save anything to SSD/HDD?