Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

CausticPuppy

macrumors 68000
Original poster
May 1, 2012
1,536
70
It seems Apple may have changed something in the latest SSD-based notebooks and/or Mountain Lion?

I have "safesleep" disabled currently:

$pmset -g | grep hibernatemode
hibernatemode 0


The default for laptops is "3" which writes an 8GB or 16GB image of RAM contents to disk, depending on how much RAM you have installed.

Once you set it 0 you're supposed to be able to delete the sleepimage file and it never comes back.


More info here:

http://www.tuaw.com/2011/08/22/why-hibernate-or-safe-sleep-mode-is-no-longer-necessary-in-os/


However, even with hibernatemode 0, the "sleepimage" file keeps getting re-created upon reboot or resume from sleep. On my other mac laptops, the file isn't recreated again once its deleted.

Anybody else with a rMBP (or 2012 Air) try this?
 
It seems Apple may have changed something in the latest SSD-based notebooks and/or Mountain Lion?

I have "safesleep" disabled currently:

$pmset -g | grep hibernatemode
hibernatemode 0


The default for laptops is "3" which writes an 8GB or 16GB image of RAM contents to disk, depending on how much RAM you have installed.

Once you set it 0 you're supposed to be able to delete the sleepimage file and it never comes back.


More info here:

http://www.tuaw.com/2011/08/22/why-hibernate-or-safe-sleep-mode-is-no-longer-necessary-in-os/


However, even with hibernatemode 0, the "sleepimage" file keeps getting re-created upon reboot or resume from sleep. On my other mac laptops, the file isn't recreated again once its deleted.

Anybody else with a rMBP (or 2012 Air) try this?

Did you find a solution to it ? Mine was fine until I updates my Air 2012 to the latest update 2.0 yesterday and now what you described is happening with me too,anyone has any clue ?
 
Did you find a solution to it ? Mine was fine until I updates my Air 2012 to the latest update 2.0 yesterday and now what you described is happening with me too,anyone has any clue ?

Oh great, it's a new "feature." I guess this means that the 13" rMBP's already had this update but now it's being applied to the mid-2012 models as well.


No, I haven't found a solution yet unfortunately. I've set my hibernate mode back to the default (3) since it doesn't seem to make a difference anyway.


One thing I've noticed is that the machine seems to hibernate after it's been asleep for a while, even when the battery is full. Upon opening the lid, the login box appears, but is unresponsive for a few seconds. I assume this is because it's displaying a static snapshot of the screen while it restores from the sleep image.

My older mac would gray out the screen and show a progress bar while it restores.
 
Set sleep mode in shell:
sudo pmset -a hibernatemode 0
Remove the image:
sudo rm /private/var/vm/sleepimage
Create a blanked file:
sudo touch /private/var/vm/sleepimage
Make file immutable:
sudo chflags uchg /private/var/vm/sleepimage

That should do it.
 
Last edited:
Set sleep mode in shell:
sudo pmset -a hibernatemode 0
Remove the image:
sudo rm /private/var/vm/sleepimage
Create a blanked file:
sudo touch /private/var/vm/sleepimage
Make file immutable:
chflags uchg private/var/vm/sleepimage

That should do it.

Hi,Thanks a lot for your response,well when I enter the last command,it gives this error "chflags: private/var/vm/sleepimage: No such file or directory" :confused:

----------

Oh great, it's a new "feature." I guess this means that the 13" rMBP's already had this update but now it's being applied to the mid-2012 models as well.


No, I haven't found a solution yet unfortunately. I've set my hibernate mode back to the default (3) since it doesn't seem to make a difference anyway.


One thing I've noticed is that the machine seems to hibernate after it's been asleep for a while, even when the battery is full. Upon opening the lid, the login box appears, but is unresponsive for a few seconds. I assume this is because it's displaying a static snapshot of the screen while it restores from the sleep image.

My older mac would gray out the screen and show a progress bar while it restores.

If it is a permanent thing,then it sucks :mad:
 
Hi,Thanks a lot for your response,well when I enter the last command,it gives this error "chflags: private/var/vm/sleepimage: No such file or directory" :confused:


You should really understand what you are running when using sudo.

The command left out a '/' before 'private'

(Not sure, may need to run with sudo since the file was created using sudo touch. Also unsure how the system will react to the restriction. do at your own risk)
 
Set sleep mode in shell:
sudo pmset -a hibernatemode 0
Remove the image:
sudo rm /private/var/vm/sleepimage
Create a blanked file:
sudo touch /private/var/vm/sleepimage
Make file immutable:
chflags uchg private/var/vm/sleepimage

That should do it.

Thank You :),just I needed to add sudo before chflags and '/' before private,thanks a lot though :D

----------

You should really understand what you are running when using sudo.

The command left out a '/' before 'private'

(Not sure, may need to run with sudo since the file was created using sudo touch. Also unsure how the system will react to the restriction. do at your own risk)

Done now :D
 
Thank You :),just I needed to add sudo before chflags and '/' before private,thanks a lot though :D

Sorry for the typo (I edited for one stop shopping).
I was posting from 'up' key history. So the sudo's could have been off. Sudo this, no need to sudo that... Glad you got it working.
As pointed out no idea on what this could do to your system over time. I suspect very little. But if you need to ask yourself if it is safe to do then don't do it. It is a workaround that worked for me only and I was really answering back OP as they seemed used to the shell.
 
Last edited:
Sorry for the typo (I edited for one stop shopping).
I was posting from 'up' key history. So the sudo's could have been off. Sudo this, no need to sudo that... Glad you got it working.
As pointed out no idea on what this could do to your system over time. I suspect very little. But if you need to ask yourself if it is safe to do then don't do it. It is a workaround that worked for me only and I was really answering back OP as they seemed used to the shell.

Well it worked and am happy,have time machine backups in case anything goes wrong,I doubt little will :cool:
 
Sorry for the typo (I edited for one stop shopping).
I was posting from 'up' key history. So the sudo's could have been off. Sudo this, no need to sudo that... Glad you got it working.
As pointed out no idea on what this could do to your system over time. I suspect very little. But if you need to ask yourself if it is safe to do then don't do it. It is a workaround that worked for me only and I was really answering back OP as they seemed used to the shell.
derbohaus, could you tell me what is going on here? I have seen some posts saying the sleep image is in /var/vm/ and as in the post above in /private/var/vm/ . Which is correct? I have "hibernatemode" set to "0", so I can't just search for the sleepimage file.
 
derbohaus, could you tell me what is going on here? I have seen some posts saying the sleep image is in /var/vm/ and as in the post above in /private/var/vm/ . Which is correct? I have "hibernatemode" set to "0", so I can't just search for the sleepimage file.

/var/vm is a symbolic link to /private/var/vm. Either one should work.
 
thanks for this. was wondering where in the blazes the space had gone to.
 
Reversing...

Set sleep mode in shell:
sudo pmset -a hibernatemode 0
Remove the image:
sudo rm /private/var/vm/sleepimage
Create a blanked file:
sudo touch /private/var/vm/sleepimage
Make file immutable:
sudo chflags uchg /private/var/vm/sleepimage

What would be the commands to reverse the above, in case a problem emerged down the line..?

And thanks...
 
sudo rm /private/var/vm/sleepimage

sudo pmset -a hibernatemode 3

You just need to remove the blank file and reset the hibernation mode and the OS will re-create.
 
I noticed this yesterday on my Retina MBP, because all of a sudden 10+ GB of disk space were being used. So far the hacky fix of creating a zero-size sleepimage file and locking it seems to work. I didn't see any log entries related to it.

This is something that Apple seriously needs a better solution for. It's not worth being overly worried about SSD wear, because if you do the math, then you can write some unrealistically huge number of gigbytes daily and you'll be fine for years and years.

The sleepimage file changes that in a drastic way. Normally you'd be hard pressed to write 8 or 10GB of data in a day. But now, every time your 8GB machine goes to sleep, either on its own or because you closed the lid, that's 8GB of writes. If that happens 10 times a day, that's 80GB. If you've got 16GB of RAM, then it's 160GB of writes a day. 1.6 TERAbytes every ten days.

Writing a huge sleepimage file is a terribly heavy-handed way to prevent one single rare case: running out of power when in sleep mode. Really, the OS should prepare for possible shutdown when sleep starts (flush caches, etc.), and if you've saved your work before sleeping, then no worries.
 
I noticed this yesterday on my Retina MBP, because all of a sudden 10+ GB of disk space were being used. So far the hacky fix of creating a zero-size sleepimage file and locking it seems to work. I didn't see any log entries related to it.

This is something that Apple seriously needs a better solution for. It's not worth being overly worried about SSD wear, because if you do the math, then you can write some unrealistically huge number of gigbytes daily and you'll be fine for years and years.

The sleepimage file changes that in a drastic way. Normally you'd be hard pressed to write 8 or 10GB of data in a day. But now, every time your 8GB machine goes to sleep, either on its own or because you closed the lid, that's 8GB of writes. If that happens 10 times a day, that's 80GB. If you've got 16GB of RAM, then it's 160GB of writes a day. 1.6 TERAbytes every ten days.

Writing a huge sleepimage file is a terribly heavy-handed way to prevent one single rare case: running out of power when in sleep mode. Really, the OS should prepare for possible shutdown when sleep starts (flush caches, etc.), and if you've saved your work before sleeping, then no worries.

The fact that OSX uses a journaled filesystem makes it even more of a non-issue.

If my rMBP battery runs out while it's asleep, then..... oh no! I'll have to wait 12 seconds for it to boot up!
 
Here's some relevant information:

http://www.ewal.net/2012/09/09/slow-wake-for-macbook-pro-retina/

There's another parameter called "standbydelay" which is supposed to delay writing the sleepimage for a certain period of time (4200 seconds by default), and then put the laptop in standby mode.

I confirmed that I still have the default value of 4200 even though my sleepimage was being written immediately upon closing the lid. However, after sleeping for 70+ minutes I experienced the "slow wake" issue reporting in the link.

I haven't seen what happens now after sleeping for 70 minutes, after using the 0-size sleepimage workaround. Maybe the thing just shuts off and then has to cold boot after 70 minutes.

It would make more sense to set the standbydelay to 24 hours or something.
 
OS X 10.8.2 seems to become unstable

...when following the instructions to avoid a sleepimage file. A number of apps simply crash, sometimes even OS X crashes completely.

I enabled the sleepimage file again and all came back to normal.

I have a Macbook Pro Retina 16GB 256 SSD running OSX 10.8.2
 
Monitor the timestamps of the sleepimage file

...when following the instructions to avoid a sleepimage file. A number of apps simply crash, sometimes even OS X crashes completely.

I enabled the sleepimage file again and all came back to normal.

I have a Macbook Pro Retina 16GB 256 SSD running OSX 10.8.2

Personally, I didn't remove the sleepimage file. Instead I simply set hibernatemode to 0 and also set standbydelay to 72000 seconds (20 hours). I did this on the 19th Nov 2012 and, as you can see by the timestamp below, the sleepimage file has not been written to since. However, it's interesting to note that the file was accessed on Nov 20th when I rebooted the machine. So we can see that the system still tries to access this file under certain circumstances even if hibernatemode is set to 0. It's probably just a cursory check at boot time, but it's still good to keep in mind.

I suggest that you put the machine asleep a few times and monitor the timestamps as you go along. It should give you an idea of what's going on.

Code:
Last write access:

$ ls -lrth /private/var/vm/sleepimage
-rw------T  1 root  wheel    16G Nov 19 13:54 sleepimage

Last read access:

$ ls-luth /private/var/vm/sleepimage
-rw------T  1 root  wheel    16G Nov 20 19:41 sleepimage
 
This is what worked for me:

Disable hibernation:
Code:
sudo pmset -a hibernatemode 0
Remove the sleep image:
Code:
sudo rm /private/var/vm/sleepimage
And finaly:
Code:
sudo ln -s /dev/null /var/vm/sleepimage
 
OK, I'm officially confused now...

I might have been a bit premature in blaming the sleepimage file disablement for the crashes...

I was in contact with VMWare because of their latest release also crashing randomly. Here is the reply AND WORKAROUND (!)

"Apple had recently released the MacBook Air and MacBook Pro Update 2.0. It includes graphics performance and reliability enhancements, which actually broke Mac's NVidia GeForce graphics driver with 3D in Fusion 5.0.2. Hence, this crashes are occurring.

See: http://blogs.vmware.com/teamfusion/2012/11/macbook-air-and-macbook-pro-update-2-0-and-vmware-fusion-5.html

So, there are two workarounds so far. Either you can use Fusion 5.0.2 and disable 3D acceleration in VM settings > Display. Or downgrade to Fusion 5.0.1. "

I disabled the 3D acceleration and my Windows 7 VM runs again properly. Here it comes what makes me all wonder: Although I enabled the sleepimage file, other software like SOAPUI for OS X also crashes or hangs just the same. However, the same SOAPUI built for Windows 7 in my VM runs now without problems (since 3D acceleration is disabled).

Could it be that the mess I have is due to an OS X update that broke the NVidia GeForce 3D support in also a few other apps?

Ouch!

----------

Personally, I didn't remove the sleepimage file. Instead I simply set hibernatemode to 0 and also set standbydelay to 72000 seconds (20 hours). I did this on the 19th Nov 2012 and, as you can see by the timestamp below, the sleepimage file has not been written to since. However, it's interesting to note that the file was accessed on Nov 20th when I rebooted the machine. So we can see that the system still tries to access this file under certain circumstances even if hibernatemode is set to 0. It's probably just a cursory check at boot time, but it's still good to keep in mind.

It is not just about the amount of data written to the SSD, but also about the lost disk space.
 
I have been looking for an answer for this issue for two days. All the fixes i found seemed to stop short of replacing the sleepimage file with a zero byte version of itself.

Thanks.

8GB back available in my 128 GB SSD

I registered just so I can say thanks for the help here.
 
For those with 16gb and without flash based hard drives will removing the sleepimage lessen wear and tear on the 750gb mechanical hard drive?
 
For me, manually replacing my 4GB sleepimage file with an empty file and locking it prevent most of the Apple menu items (sleep, restart, log off, etc.) from working. I also can't open up various applications (Finder error -600).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.