Monday, November 3, 2008

Make your Mac sleep better with SmartSleep...

Note: If you just want to cut to the chase skip down to the bottom paragraph...

...if any of you spent time around me with my trusty old PowerBook G4 for any amount of time, you would know that about 1 out of every 20 times I tried to bring it out of sleep it would lock up and I'd have to hard reboot. I never figured out what caused it. I did some voodoo things to prevent it, like make sure that I didn't plug or unplug the power adaptor while it was sleeping, same with USB devices, and using this voodoo I could generally get it to the point that it only locked up once a week or so. The machine had this problem even while Nicole had it while I was on my mission, and she had none of the third party hackery installed that I did, so I'm reasonably sure it wasn't simply a software glitch.

One of the things I was most excited about with my new machine was the prospect of reliable sleep. This morning, anticipating flawless wakery, I recklessly removed my new ProBook (Er...MacBook Pro) from my desk by removing it's audio, USB, and power cord tethers on my desk. I bought it out and laid it on the couch and had my breakfast.

You can imagine my horror then when I opened the lid and...nothing, nada, it had frozen up. 

Well that shot my chances of doing homework this morning as I instantly started researching the issue instead. I don't know for sure what caused it, but I did find some people on the internet complaining about the SafeSleep 'feature' in new Macs, and finding that their sleep was more reliable when they disabled SafeSleep.

Since most people are pretty familiar with Windows I'm going to use Windows terminology to explain what SafeSleep is. On windows when you "sleep" the computer, the RAM remains powered on. When you "hibernate" the computer the contents of RAM are written to disk and the machine powers 100% off. SafeSleep is a combination of both. The contents of RAM are written to disk, but then the RAM remains powered on. 99% of the time you wake up normally, but the 1% of the time your battery totally dies, or you swap batteries, or something like that, you can still power up faster than a total startup, since the machine just falls from "sleep" into "hibernate" and simply restores your hibernate state when you wake up.

Herein lies the problem, the SafeSleep requires the contents of RAM to be written to disk every time you put the machine in sleep. I have 4 gig of RAM in this machine and I am currently using just over 2 of that. That means when I shut the machine's lid the hard drive doesn't stop spinning for almost a minute while the contents of the RAM are written out to disk. If I make a small change while in sleep, like plugging or unplugging USB, the machine has to wake up and go back to sleep, prompting the contents of RAM to get written out to disk yet again.

I can disable safesleep, but what about that 1% of the time when I really wish I had it?

If you're still reading...what a trooper...

Enter SafeSleep

SmartSleep is a brilliant preference pane written by one of our trusty Mac developer friends. The way it works is to run a little script about every 10 minutes. The script fetches your battery life. If your battery is mostly full, the script disables SafeSleep for you. So your machine sleeps and wakes...instantly. If your battery is mostly dead, however, it helps you out by enabling the SafeSleep again. This doesn't take care of you if you want to hot swap a battery, but I only own 1 battery anyway. 

It's brilliant, an if you've got a Mac Portable (That's *several* of you) I recommend you go get SmartSleep now!

2 comments:

orangemily said...

I'm glad you found a solution!

Nicole said...

um, I have a dell.