In the previous Miscellaneous Ramblings Mailbag, I posted a query from a reader named
Richard asking why his MacBook takes a longer time for the hard drive
to settle down after he selects sleep mode than older PowerPC 'Books
did.
I unfortunately wasn't able to answer that, but as we shall see
below, a veritable cast of thousands rose to the occasion.
Ironically, just a few hours after I filed the Mailbag with my reply
to Richard on this topic, I happened to run across
an article on RecoveryForce discussing that very issue and cluing
me in as to why the sleep lag.
Actually, I then recalled that had heard about "Safe Sleep" some time ago when it was
announced, long before I bought my MacBook, but it had slipped my
mind.
Thanks to everyone who who wrote with explanations and links.
Charles
Safe Sleep Writes to Disk
From Dan Knight:
Charles, please refer Rich to this article:
How to Disable Safe Sleep in Mac OS 10
What's happening is that his MacBook is writing the contents of RAM
to the hard drive before it truly goes to sleep. This makes restarts
faster, but it does risk the drive if the 'Book is moved before backup
of RAM is completed. The article explains how to disable this
behavior.
Dan
MacBook Sleep - Why It Takes Longer
From Josh:
Charles,
It is my understanding that MacBooks take 20-30 seconds to go to
sleep because the computer is storing all of the contents of the RAM
onto the hard drive. That way, if the computer stays asleep so long
that the battery runs out, when you plug the computer back in, it will
simply restore itself to the same state it was in when you triggered
sleep in the first place - all the same applications, windows, even
webpages come back to the way they were. It's pretty cool, actually -
similar to hibernate mode in Windows, but much slicker, as is generally
the case with Apple products.
Incidentally, Apple recommends that MacBook owners refresh their
batteries monthly by letting them run all the way down until sleep is
triggered, hard powering down, then powering back up again. When you do
this, however, let the computer go fully to sleep before powering down
- otherwise, you're cutting off power while the hard drive is still
spinning - never a good idea.
Best regards,
Josh
Re: Unexpected MacBook Sleep Behavior
From Patrick:
Hi Charles,
I noticed your recent exchange on Low End Mac with another reader
about newer Mac portables and the amount of time they take to complete
going into sleep mode. I encountered this issue back when I got my
current work machine (then brand new) in early 2007. On investigation I
learned that Intel Macs write the entire contents of RAM to their hard
disks on entering sleep by default. The process is called Safe Sleep
apparently, and PowerPC portables didn't use it by default. In the case
of my machine, this meant rewriting a 3 gig file to disk every
time I closed the lid, not a lightning fast operation and (to my mind)
an excessive safeguard.
I discovered that it's possible to reconfigure newer Macs to use the
older sleep mode (where RAM stays powered but isn't duplicated to
disk). The terminal commands are simple, and as well as speeding up the
sleep process and reducing disk wear, it allows the user to reclaim a
substantial chunk of storage space. There's an excellent MacWorld
article summarising the issue and outlining the various options for
changing it: Set
Newer Portable Macs' Sleep Mode.
I've now been using my MBP in old fashioned "unsafe" sleep mode for
two years and haven't yet had cause to regret changing it. I hope this
is helpful to you and your readers.
Cheers
- Patrick
Hi Patrick. It is. Thanks for the advice and link.
Charles
Unexpected MacBook Sleep Behavior
From Sam:
Charles
In your May 27th column, Rich asked about the apparently odd sleep
function in his Intel Mac. It's actually a feature called Safe Sleep.
When you shut the lid, your entire RAM state is saved to disk. This
ensures that in a power failure, you can resume working where you left
off. If you, right now, close the lid of your MacBook, wait for the
sleep light to begin pulsating, and disconnect all power sources
(battery/power adapter), the light will go dark. When you press the
power button, you will see an odd grey screen with a progress bar at
the bottom center. When it completes, you will be shown whatever you
have the MacBook set to do upon waking from sleep.
This allows for quick swapping of batteries and replaced the reserve
power found in PowerPC 'Books. It can be turned off with the following
terminal commands:
- Turn Safe Sleep Off: sudo pmset -a hibernatemode 0 Delete
Sleepimage
- Saves ~size of RAM on hard disk: sudo rm
/var/vm/sleepimage
- Turn Safe Sleep back on: sudo pmset -a hibernatemode
3
Safe Sleep may be a hassle for you if you rarely run your MacBook
unplugged or away from power. Otherwise, you should leave it on, being
cautious not to move the 'Book until the noise has ceased.
- Sam
Thanks for the info, Sam.
Charles
MacBook Sleep
From Chris:
When putting a MacBook to sleep, the hard drive spins for about 20
seconds as it is saving memory onto disk. You can take the battery out
and pull the power cord after that, and it will still wake up in the
state that it was in before you put it to sleep, which is pretty clever
if you ask me.
This situation is perfect for someone who put their MacBook to sleep
a month ago running on battery power and still don't lose anything from
the state that it was last in despite the fact that the battery ran out
of juice 2 weeks beforehand
http://support.apple.com/kb/HT1756
Greetings from Chris
Safe Sleep
From Henry:
Hi Charles,
Your new MacBook saves the contents of RAM to the hard disk before
going to sleep in case the battery gets low. PowerBooks didn't; they
kept RAM refreshed, as do the new 'Books, on battery power. However, if
the system sleeps long enough to run down the battery and shuts down,
the PowerBooks will lose RAM contents and have to do a cold boot. The
MacBook can reload RAM from disk and resume where it went to sleep.
You are right to wait for the sleep light before moving your
MacBook, since the disk is in use.
Henry
Re: MacBook Sleep Behaviour
From Richard:
Hi Charles,
Regarding the mailbag entry about the MacBook taking a long time
before the power LED starts pulsing - I believe this is due to the
"Safe Sleep" feature on the Intel Macs. As well as keeping the RAM
powered to preserve memory contents, Intel Macs and late-model
PowerBooks also save the contents of the RAM to disk when they go into
sleep mode. This means that in event of the battery being removed or
going flat, the memory contents are preserved on disk, and will be
copied back from disk to RAM when the system is powered on. The
downside of this is, of course, that it takes longer to go into sleep
mode as it copies the RAM contents to disk.
This behaviour can be controled with the Deep Sleep dashboard widget
( http://deepsleep.free.fr/ ) that allows Safe Sleep to be disabled,
permitting a faster sleep by not copying the RAM to disk. It also
allows you to force "Deep Sleep" mode, where the RAM is copied to disk
and then the system is shut down, emulating the "Hibernate" function of
Wintel machines. This mode uses no power at all while sleeping, but
takes longer to wake up.
Hope this helps
Richard Halkyard
Hi Richard,
That Dashboard widget sounds like a low hassle way to
control this behavior.
Thanks for the link.
Charles
Re: Unexpected MacBook Sleep Behavior
From Kev:
I was reading about your and Rich's experience in the last
Miscellaneous Ramblings mailbag (05/27). I think the lag before sleep
ensues is the "safe sleep" feature kicking in. Simply put, it copies
the contents of the RAM to the hard drive, similar to a PC's
hibernation, in the event that your MacBook looses power. This allows
you to swap batteries while keeping your work going. You might try it
out to see how it works.
Sincerely,
Kev Kitchens
Odd MacBook Sleep
From John:
Hi Charles,
Apple introduced Safe Sleep sometime in the PowerBook G4 era after I
bought mine in early 2003. Older 'Books rely entirely on their battery
powered memory contents, which will drain within a few days and force a
reboot when the Mac is next turned on.
Newer models save the entire contents of their memory - often 1-4
gigabytes now - to their hard drive in the moments after you close the
lid to send them to sleep. That way, all battery can be lost yet the
session will be safe to restore from the hard drive. It's a combination
of sleep and hibernation. Typically, you open your Mac back up again
while the battery is still good, so you don't trigger the full image
load from the hard drive. But for safety, the image is written every
time the system enters sleep, which is likely what's been noticed.
It's possible to alter the behaviour via some Terminal magic. But
the defaults are quite safe and best left be.
- John
Regarding 'Unexpected MacBook Sleep Behavior'
From Sylvain:
Hi Charles,
Here are just a few thoughts about Rich's question and your answer
on how his new MacBook has a different sleep behavior than his iBook
G4. Indeed, newer Apple laptops take a few seconds before entering
sleep, while older laptops sleep almost immediatly. In my
understanding, this is implied by what Apple calls "Safe Sleep": Before
entering sleep, Mac OS X writes the whole content of the RAM to the
disk. This can be found in the file
/private/var/vm/sleepimage.
That way, whenever the computer loses all power while asleep (when
the battery gets completely empty after a couple of days), you can find
your current work, open documents and applications just as you left
them when you plug it back in, without having to restart.
This is well explained in that old Mac 911
article at Macworld.
Should you want it, you always can disable Safe Sleep and get rid of
the sleepimage file to stick with the old behavior through a few
command lines, or with a GUI utility, like for example SmartSleep.
I hope I have well understood Rich's question and this is not old
news for you, and I apologize for my bad English, since it's not my
main language, and hopefully I haven't misunderstood the whole
thing!
Best regards,
Sylvain
Hi Sylvain,
Your English is just fine!
Charles
Safe Sleep
From David:
Charles,
Hello.
It is called Safe Sleep. That sleep delay is the contents of RAM
being written to disk as a file named "sleepimage". The size of the
file is the same size as the total RAM.
From Apple: About
Safe Sleep
To revert back to the old way requires a trip to the Terminal, as
nicely detailed in this
Macworld article.
I had set aside a smaller partition to boot in for general
maintenance. With 4 GB of RAM, the sleepimage file was too big.
The article in Macworld was quite helpful in recovering the free space.
I felt that having the RAM backup file in this kind of partition was
unnecessary.
I have seen the RAM recovery from disk in action. The display
content becomes ghostly white with faint images and a progress bar.
After loading is done, it all goes back to normal.
Regards,
David
Hi David,
Good point about the issue with small hard drive
partitions.
Charles
MacBook Sleep vs. PPC Sleep
From John:
Intel-based MacBooks all do something different called Safe Dleep.
It can take up to 15 seconds for the sleep light to begin pulsing.
Prior to that, the hard drive is still spinning. It is basically
paging out the contents of memory to the hard drive.
Wake from sleep is faster.
I was used to my old iBook's instant sleep by closing.
Highly recommend you do not begin moving Intel Macs around until the
sleep light is pulsing. Hard drive could get hosed or you could
(through jostling the sleep switch) cause a between sleep/wake
crash/hang which cannot reach system logs and requires force power off
and causes it to heat up a lot in your bag.
John
'Slow Sleep' Behavior
From Rich:
Charles (and Dan):
Thanks for the article about the 'slow sleep' behavior of my
MacBook. The article referenced had a macro for altering the MB's sleep
process, but I've since found a Preference Pane that will do
the same thing:
Apple also offers this
through their Downloads page.
Thanks guys!
Rich
Hi Rich,
Thank you for the info and links!
Charles
Go to Charles Moore's Mailbag index.