Inert Detritus The Internet's dust bunnies

8 March 2008 @ 10am

SmartSleep: OS X Hibernation Made Easy

This pref­er­ence pane deserves a whole blog post. Smart­Sleep is a tiny pref­er­ence pane that changes the sleep­ing behav­iour of any Mac that sup­ports hiber­na­tion. Here’s some quick back­ground infor­ma­tion (skip the next two para­graphs if you know how hiber­na­tion works).

By default, new Intel-based lap­tops save part of their RAM to disk every time they’re put to sleep (all active pages not all ready in on-disk vir­tu­al mem­o­ry, and all wired pages, for the VM nerds out there). If the machine los­es pow­er while it’s asleep (bat­tery drains, or because of a bat­tery swap), OS X is able to read in the hiber­nat­ed mem­o­ry con­tents and restore the cur­rent state of the machine, there­by pre­serv­ing all open work, doc­u­ments, appli­ca­tions, et cetera.

As you might imag­ine, on machines with 2 or more GB of RAM with more than a few appli­ca­tions open, this can take a while (upwards of 30–40 sec­onds). When you con­sid­er that new Mac­Book Pros come with 2 GB stan­dard, and most users don’t need this “safe­ty net”, there’s a pletho­ra of hints and wid­gets online for turn­ing off hiber­na­tion to make the machine sleep faster.

But this means that hiber­na­tion is per­ma­nen­ly turned off when you need it most: when your bat­tery is very low. Smart­Sleep takes care of all that. It lets you set the typ­i­cal modes: “sleep and hiber­nate” (the out-of-the-box behav­iour for OS X), “sleep only” (so hiber­na­tion is off), and “hiber­nate only” (can’t think of a time I’d use that, but it’s there any­way), but it adds one more: “smart sleep”. “Smart sleep” puts the machine to reg­u­lar sleep if the bat­tery is above a user-spec­i­fied per­cent­age. Below that per­cent­age, it changes to “sleep and hiber­nate”, and below 5% or less than 5 min­utes remain­ing, it changes to hiber­nate only (I dis­agree with that decision).

I have my machine set to “smart sleep”, and the per­cent­age set to 10%: the vast major­i­ty of the time, I don’t need hiber­na­tion turned on, but if I’m on cam­pus, run my bat­tery down to 3–4%, and it’ll be sev­er­al hours before I’ll find a charg­er, it’ll hiber­nate mem­o­ry and save what­ev­er I have open (there­by pro­tect­ing me from the remain­ing bat­tery pow­er drain­ing while the machine is asleep).

Smart­Sleep is fan­tas­tic: Apple should build auto-switch­ing of hiber­na­tion modes into OS X in the future.