Inert Detritus The Internet's dust bunnies

Posted
8 March 2008 @ 10am

SmartSleep: OS X Hibernation Made Easy

This preference pane deserves a whole blog post. SmartSleep is a tiny preference pane that changes the sleeping behaviour of any Mac that supports hibernation. Here’s some quick background information (skip the next two paragraphs if you know how hibernation works).

By default, new Intel-based laptops save part of their RAM to disk every time they’re put to sleep (all active pages not all ready in on-disk virtual memory, and all wired pages, for the VM nerds out there). If the machine loses power while it’s asleep (battery drains, or because of a battery swap), OS X is able to read in the hibernated memory contents and restore the current state of the machine, thereby preserving all open work, documents, applications, et cetera.

As you might imagine, on machines with 2 or more GB of RAM with more than a few applications open, this can take a while (upwards of 30–40 seconds). When you consider that new MacBook Pros come with 2 GB standard, and most users don’t need this “safety net”, there’s a plethora of hints and widgets online for turning off hibernation to make the machine sleep faster.

But this means that hibernation is permanenly turned off when you need it most: when your battery is very low. SmartSleep takes care of all that. It lets you set the typical modes: “sleep and hibernate” (the out-of-the-box behaviour for OS X), “sleep only” (so hibernation is off), and “hibernate only” (can’t think of a time I’d use that, but it’s there anyway), but it adds one more: “smart sleep”. “Smart sleep” puts the machine to regular sleep if the battery is above a user-specified percentage. Below that percentage, it changes to “sleep and hibernate”, and below 5% or less than 5 minutes remaining, it changes to hibernate only (I disagree with that decision).

I have my machine set to “smart sleep”, and the percentage set to 10%: the vast majority of the time, I don’t need hibernation turned on, but if I’m on campus, run my battery down to 3–4%, and it’ll be several hours before I’ll find a charger, it’ll hibernate memory and save whatever I have open (thereby protecting me from the remaining battery power draining while the machine is asleep).

SmartSleep is fantastic: Apple should build auto-switching of hibernation modes into OS X in the future.