How do I stop my MacBook Pro from randomly freezing when trying to go to sleep?

Solution 1:

I would try adjusting your procedure. Since as noted the quoted steps provided below in practice are causing you to unintentionally wake the Mac from sleep in step 3, which may also problematically be waking it from sleep before it finishes going to sleep in the first place. So in a sense you were telling your MacBook Air to go to sleep and while your at it wake up from sleep, remove a display and all this other stuff at the same time. That may be the cause of the freezing, the shock of all the external devices getting removed while in sleep or while the mac is going to sleep.

  1. Move mouse to HotCorner to put monitor to sleep (I do this instead of closing the lid since Lion has lid closing assume the external is taking over as primary display)
  2. Close lid to put computer to sleep
  3. Disconnect cables (power, display port, usb; maybe ethernet and audio depending on location).

USB activity as noted in Mac OS X: Why your Mac might not sleep or stay in sleep mode is a perfect way to wake your mac from sleep.

I would recommend doing the following instead:

  1. Save your important files and data in open applications in case things go wrong.
  2. Disconnect cables (power, display port, usb; maybe ethernet and audio depending on location).
  3. Wait for you mac to recognize that the external display is disconnected, usually screen fades to blue for a few seconds, before going back to normal view of your Mac. etc.

  4. Close lid to put computer to sleep or choose Apple > Sleep, etc...

  5. Verify the sleep indicator light is slowly pulsing, before placing the MacBook into any case.

So ya try this out and see if it stops the random freezing. If it does not then there may be other hardware / software problems at hand, check your system logs, etc.

Solution 2:

I've also found that OS X is prone to not properly suspend with external devices attached; in my case the usual trigger seems to be USB hard drives, but the external monitor might also trigger it. The external drive version predates Lion; my old MacBook Pro running Snow Leopard also had it happen regularly. I've also noticed it seems to require a certain minimum uptime to happen, which makes me think some program (Spotlight/md?) is failing to let go of the hard drive in a timely fashion and aborting the suspend.

Solution 3:

The problem may be due to SafeSleep, which is enabled by default on Macbooks and causes the laptop to write out the RAM to disk when put to sleep. Try turning off SafeSleep and see if that helps. My 2011 Macbook Pro started hanging occasionally when closing the lid after I upgraded to 8GB RAM, and turning off SafeSleep seems to have stopped it.

http://www.markc.me.uk/blog/files/OSXSafeSleep.html