sleepimage – the Mac OS X sleepimage file explained

Oct 11, 2010 - 21 Comments

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.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: Manish Patel in Mac OS X

21 Comments

» Comments RSS Feed

  1. JB says:

    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
    ==============================

    • JB says:

      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 :)

      • PD says:

        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.

        • Stuart 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.

    • Mario says:

      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?

  2. danztensai says:

    Wow.Great..thank’s a lot..now i’m understand

  3. Fishcake21 says:

    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…

  4. […] 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 […]

  5. […] 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 […]

  6. Pathosh says:

    From man pmset:

    Please note that hibernatefile may only point to a file located on the root volume.

  7. […] 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 […]

  8. Joe says:

    Can this cause any problems in the long run? If I close the lid will it just shut off?

  9. Avi says:

    16 Gb. I have 16 GB of ram.

  10. Hew says:

    FYI, 12 gb RAM takes about 20 sec to wake up on my 3.06 GHz core i3 desktop

  11. steve says:

    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.

  12. ghostlines says:

    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!

  13. W_ says:

    17GB sleepimage… for 16GB RAM… okay…

    • G says:

      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.

  14. […] 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 […]

  15. […] 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 […]

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates