Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Hardware > Notebooks > MacBook Pro

Reply
 
Thread Tools Search this Thread Display Modes
Old Oct 31, 2012, 12:19 PM   #1
CausticPuppy
macrumors 65816
 
Join Date: May 2012
Sleepimage keeps coming back even with SafeSleep disabled

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-h...cessary-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?
__________________
2011 Mac Mini Server, 16 GB RAM, 256GB Crucial M4 SSD, 500GB HDD + 3TB NAS
Haswell rMBP 13" - i7/512GB
Mac Mini 1.83GHz Core2Duo, 3GB RAM, 60GB SSD
iPad Air/iPhone5S
CausticPuppy is offline   0 Reply With Quote
Old Oct 31, 2012, 02:45 PM   #2
whiteonline
macrumors regular
 
Join Date: Aug 2011
Are you changing the energy saver options, then selecting to set them to default?
whiteonline is offline   0 Reply With Quote
Old Nov 9, 2012, 11:24 AM   #3
SWPROX
macrumors member
 
Join Date: Oct 2012
Location: Canada
Quote:
Originally Posted by CausticPuppy View Post
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-h...cessary-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 ?
SWPROX is offline   0 Reply With Quote
Old Nov 9, 2012, 12:25 PM   #4
CausticPuppy
Thread Starter
macrumors 65816
 
Join Date: May 2012
Quote:
Originally Posted by SWPROX View Post
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.
__________________
2011 Mac Mini Server, 16 GB RAM, 256GB Crucial M4 SSD, 500GB HDD + 3TB NAS
Haswell rMBP 13" - i7/512GB
Mac Mini 1.83GHz Core2Duo, 3GB RAM, 60GB SSD
iPad Air/iPhone5S
CausticPuppy is offline   0 Reply With Quote
Old Nov 9, 2012, 01:13 PM   #5
derbothaus
macrumors 601
 
derbothaus's Avatar
 
Join Date: Jul 2010
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.
__________________
Mac Pro W3680, GTX 680, 12GB DDR3, SSD; MBP, 2.6GHz Core i7, 16GB DDR3, SSD; Eizo fs2333

Last edited by derbothaus; Nov 9, 2012 at 06:52 PM. Reason: command typos fixed. Thanks!
derbothaus is offline   3 Reply With Quote
Old Nov 9, 2012, 01:28 PM   #6
SWPROX
macrumors member
 
Join Date: Oct 2012
Location: Canada
Quote:
Originally Posted by derbothaus View Post
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"

----------

Quote:
Originally Posted by CausticPuppy View Post
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
SWPROX is offline   0 Reply With Quote
Old Nov 9, 2012, 01:41 PM   #7
whiteonline
macrumors regular
 
Join Date: Aug 2011
Quote:
Originally Posted by SWPROX View Post
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" [COLOR="#808080"]
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)
whiteonline is offline   1 Reply With Quote
Old Nov 9, 2012, 01:42 PM   #8
SWPROX
macrumors member
 
Join Date: Oct 2012
Location: Canada
Quote:
Originally Posted by derbothaus View Post
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

----------

Quote:
Originally Posted by whiteonline View Post
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
SWPROX is offline   0 Reply With Quote
Old Nov 9, 2012, 06:53 PM   #9
derbothaus
macrumors 601
 
derbothaus's Avatar
 
Join Date: Jul 2010
Quote:
Originally Posted by SWPROX View Post
Thank You ,just I needed to add sudo before chflags and '/' before private,thanks a lot though
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.
__________________
Mac Pro W3680, GTX 680, 12GB DDR3, SSD; MBP, 2.6GHz Core i7, 16GB DDR3, SSD; Eizo fs2333

Last edited by derbothaus; Nov 9, 2012 at 07:32 PM.
derbothaus is offline   0 Reply With Quote
Old Nov 9, 2012, 08:59 PM   #10
SWPROX
macrumors member
 
Join Date: Oct 2012
Location: Canada
Quote:
Originally Posted by derbothaus View Post
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
SWPROX is offline   0 Reply With Quote
Old Nov 9, 2012, 10:02 PM   #11
davidlv
macrumors 65816
 
Join Date: Apr 2009
Location: Kyoto, Japan
Quote:
Originally Posted by derbothaus View Post
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.
__________________
MacBook Pro 15" Late 2011, 2.2GHz, 16GB Patriot RAM, 256GB Plextor M5P Xtreme SSD ; Mac Mini 2011 Base model 8GB RAM, 256GB Plextor M5S SSD
davidlv is offline   0 Reply With Quote
Old Nov 10, 2012, 01:59 AM   #12
derbothaus
macrumors 601
 
derbothaus's Avatar
 
Join Date: Jul 2010
Quote:
Originally Posted by davidlv View Post
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.
__________________
Mac Pro W3680, GTX 680, 12GB DDR3, SSD; MBP, 2.6GHz Core i7, 16GB DDR3, SSD; Eizo fs2333
derbothaus is offline   0 Reply With Quote
Old Nov 11, 2012, 05:07 AM   #13
t0rr3s
macrumors 6502
 
Join Date: Dec 2010
thanks for this. was wondering where in the blazes the space had gone to.
__________________
Mac Pro 3,1 3.2 GHz Octocore 16GB RAM Radeon HD 5770 Intel X25-M 160GB SSD 4TB Caviar Black 30" ACD
MBA 2012 11" 1.7 GHz 8GB 128GB
t0rr3s is offline   0 Reply With Quote
Old Nov 11, 2012, 04:13 PM   #14
John Fridinger
macrumors newbie
 
Join Date: Jul 2012
Reversing...

Quote:
Originally Posted by derbothaus View Post
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...
John Fridinger is offline   0 Reply With Quote
Old Nov 11, 2012, 08:41 PM   #15
derbothaus
macrumors 601
 
derbothaus's Avatar
 
Join Date: Jul 2010
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.
__________________
Mac Pro W3680, GTX 680, 12GB DDR3, SSD; MBP, 2.6GHz Core i7, 16GB DDR3, SSD; Eizo fs2333
derbothaus is offline   0 Reply With Quote
Old Nov 12, 2012, 11:57 AM   #16
junkster
macrumors regular
 
Join Date: Nov 2006
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.
junkster is offline   0 Reply With Quote
Old Nov 12, 2012, 12:01 PM   #17
CausticPuppy
Thread Starter
macrumors 65816
 
Join Date: May 2012
Quote:
Originally Posted by junkster View Post
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!
__________________
2011 Mac Mini Server, 16 GB RAM, 256GB Crucial M4 SSD, 500GB HDD + 3TB NAS
Haswell rMBP 13" - i7/512GB
Mac Mini 1.83GHz Core2Duo, 3GB RAM, 60GB SSD
iPad Air/iPhone5S
CausticPuppy is offline   0 Reply With Quote
Old Nov 12, 2012, 01:25 PM   #18
CausticPuppy
Thread Starter
macrumors 65816
 
Join Date: May 2012
Here's some relevant information:

http://www.ewal.net/2012/09/09/slow-...ok-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.
__________________
2011 Mac Mini Server, 16 GB RAM, 256GB Crucial M4 SSD, 500GB HDD + 3TB NAS
Haswell rMBP 13" - i7/512GB
Mac Mini 1.83GHz Core2Duo, 3GB RAM, 60GB SSD
iPad Air/iPhone5S
CausticPuppy is offline   0 Reply With Quote
Old Nov 22, 2012, 11:25 AM   #19
mwille64
macrumors newbie
 
Join Date: Nov 2012
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
mwille64 is offline   0 Reply With Quote
Old Nov 22, 2012, 12:35 PM   #20
AirThis
macrumors 6502
 
Join Date: Mar 2012
Monitor the timestamps of the sleepimage file

Quote:
Originally Posted by mwille64 View Post
...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
__________________
Mac Mini 2009 - Iphone 4 16GB - rMBP 2.6 - Time Capsule 2TB
AirThis is offline   0 Reply With Quote
Old Nov 22, 2012, 03:57 PM   #21
sweebee
macrumors newbie
 
Join Date: Dec 2010
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
sweebee is offline   0 Reply With Quote
Old Nov 23, 2012, 09:40 AM   #22
mwille64
macrumors newbie
 
Join Date: Nov 2012
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/2...-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!

----------

Quote:
Originally Posted by AirThis View Post
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.
mwille64 is offline   0 Reply With Quote
Old Dec 2, 2012, 01:33 PM   #23
edgarp
macrumors newbie
 
Join Date: Dec 2012
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.
edgarp is offline   0 Reply With Quote
Old Dec 2, 2012, 02:14 PM   #24
Iphone4sinwhite
macrumors regular
 
Join Date: Oct 2011
For those with 16gb and without flash based hard drives will removing the sleepimage lessen wear and tear on the 750gb mechanical hard drive?
Iphone4sinwhite is offline   0 Reply With Quote
Old Dec 12, 2012, 10:04 AM   #25
besweeet2
Banned
 
Join Date: Sep 2012
Location: San Antonio, TX
Send a message via Skype™ to besweeet2
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).
besweeet2 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Hardware > Notebooks > MacBook Pro

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 10:43 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC