There are two ways that computers sleep (a.k.a. being suspended). One way is to keep the RAM powered on, and turn the rest of the computer off (suspend to RAM). This allows the comptuer to wake almost instantly. The disadvantage is that if your computer loses power – say, the battery runs out – you lose your session, and your computer will boot up normally when you turn it on.
The second way is to write the contents of RAM to the hard disc, and turn the computer off completely (suspend to disc). This way you can unplug it or disconnect the battery, and you won’t lose your session. The disadvantage is, it takes longer to sleep and to wake. The more RAM you have, the longer it takes. Current MacBook Pros can have 16GB of memory, which can take a couple of minutes to write to and read from disc.
Recent versions of OS X, at least from 10.5, possibly earlier, ships with its sleep mode configured to do both of the above. This works great! You get fast wake-up times, but if your battery runs out, you don’t lose your session either. On older MacBooks/MacBook Pros this means that you can swap out the battery, and still have your session in tact.
The sleep modes are configured by the ‘hibernatemode’ directive, and you can check yours as follows:
$ pmset -g | grep hibernatemode hibernatemode 3
The hibernate modes are as follows:
0: Suspend to RAM. RAM remains powered on while sleeping, safe sleep is disabled, wake is instant.
1: Suspend to disc, a.k.a safe sleep. RAM contents is written to disk, computer shuts down completely. Slower to wake up.
3: RAM is powered on while sleeping, but RAM contents are also written to disk before sleeping.
5: Same as mode 1, but for using secure virtual memory.
7: Same as mode 3, but for using secure virtual memory.
Of course, mode 3 still means that your shiny MacBook is spending a fair bit of time writing to disc every time you close the lid. Even my 2008 vintage MacBook Pro can go about a month in mode 0 or 3 before the (now 5 year old) battery runs out. So for all practical purposes, suspend to disc is completely unneccessary. To set it to 0, do the following:
$ sudo pmset -a hibernatemode 0
Once you’ve set it to 0, you can free up some space by removing the RAM image:
$ sudo rm /var/vm/sleepimage