Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have disabled the "Restore windows when quitting and re-opening apps" checkbox in the General preferences pane in Lion, but after a recent sudden power loss (no battery) my iMac restarted in exactly the same state as I had left it the night before. What feature of Lion is making this (miracle) possible, and how do I ensure that it remans enabled?


I read for example that I can "disable Resume", because it "duplicates" something called "Safe Sleep", but I'm not sure what any of these features are, how they are related, or how I can control them. For example, does the behavior I saw in my recent power loss mean that my machine had gone to sleep between my last use and the power failure, or is some kind of snapshotting taking place continuously in the background? I also understand that there are different "kinds" of sleep. If sleep is indeed necessary, do different triggers (keyboard, script, idle, etc.) for sleep result in different "kinds" of sleep.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Resume, counterintuitively, does not actually save anything itself. It simply relaunches all the applications that were running when you shut your computer down. It's the job of those Lion-compatible applications to restore their windows.

Safe sleep, on the other hand, saves a snapshot of your RAM to your HDD when you put your computer to sleep. In case of power failure, the machine boots from this file on startup.

Safe sleep is the only time (that I know of) that OS X saves its RAM.

You can use the pmset command line utility (specifically the sudo pmset -a hibernatemode x command where x is the sleep mode) to change the sleep mode, although there is no significant benefit in doing this.

The three main different kinds of sleep are as follows (from the pmset man page):

hibernatemode = 0 (binary 0000) by default on supported desktops. The system will not back memory up to persistent storage. The system must wake from the contents of memory; the system will lose context on power loss. This is, historically, plain old sleep.

hibernatemode = 3 (binary 0011) by default on supported portables. The system will store a copy of memory to persistent storage (the disk), and will power memory during sleep. The system will wake from memory, unless a power loss forces it to restore from disk image.

hibernatemode = 25 (binary 0001 1001) is only settable via pmset. The system will store a copy of memory to persistent storage (the disk), and will remove power to memory. The system will restore from disk image. If you want "hibernation" - slower sleeps, slower wakes, and better battery life, you should use this setting.

As I stated before, configuring the sleep mode is not recommended (again from the pmset man page):

We do not recommend modifying hibernation settings. Any changes you make are not supported. If you choose to do so anyway, we recommend using one of these three settings. For your sake and mine, please don't use anything other 0, 3, or 25.

I don't know about the script vs. user issue, although I highly doubt there is a difference.

share|improve this answer
    
Is a RAM snapshot saved by any other process, or is (safe) sleep the only way? What other "kinds" of sleep are there and how are they activated and configured? Does it matter how sleep is triggered (e.g. idle time vs. a user script)? –  raxacoricofallapatorius Dec 16 '11 at 20:20
1  
@raxacoricofallapatorius See answer edit. –  spudwaffle Dec 17 '11 at 0:56
    
So it sounds like the article I linked to in my question is incorrect: Resume is nothing like a replacement for the RAM snapshotting that's done by Safe Sleep (e.g., by hibernatemode 3 in your answer). –  raxacoricofallapatorius Dec 17 '11 at 2:51
    
Yes, that article is incorrect. While Safe Sleep and Resume accomplish the same thing, they do it in different ways. Also be aware that some applications, particularly those not made for Lion, don't work with Resume, and will simply launch without restoring their previous state. –  spudwaffle Dec 17 '11 at 5:06

The other answer is too complex ^

"safe sleep" aka hibernate on windows: if enabled, will sleep ur computer but also write the RAM to a file on the hard drive. Restarting the power will allow u continue from the previous state.

"Resume" saves the states of open applications when turning off/logging off your computer to meta files, and later freshly reloads your OS and Apps, but resumes based on the specifications of the meta files. Resume is a convince, not a safety net. I recommend you turn it on, might save some time and it doesn't really cost you anything

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.