If you have a MacBook Pro with several gigabytes of RAM, you may have noticed that Mac OS X will lock up when you try to wake the laptop up. This can be very frustrating and requires you to hold the power button in for 5 seconds and turning it back on.
I run 2 or 3 VMware Fusion virtual machines at the same time and that eats up a ton of RAM, but it’s OK since my laptop has 8GB of memory. My machine would lock up when I tried to wake it up. I found that it would sometimes be OK leaving 1 virtual machine running, but if I left 2 running, it would almost always lock up.
So, I did some research and discovered the problem has to do with Mac OS X’s power management, specifically the hibernatemode. The value is a bitfield that has the following options:
- 0 (0000) Disables SafeSleep. Memory state is maintained until battery power is gone in which case the computer turns off completely.
- 1 (0001) Enables hibernation, writes memory contents to hibernation image, and immediately goes to sleep.
- 3 (0011) Maintains memory state while sleeping, but when the battery power is nearly gone, it will write the contents of the memory to hibernation image.
On laptops, the default value is 3. On desktops, the default is 0.
To fix the problem, you simply need to set the hibernatemode to 0. From a Mac OS X terminal, run the following:
sudo pmset -a hibernatemode 0
Then reboot your laptop and enjoy lock-free waking up!
At this point, hibernation is disabled and that means you can delete the hibernation file and free up a couple gigs of disk space!
sudo rm -f /var/vm/sleepimage
One side note, Microsoft Windows actually disables hibernating on computers with 4GB or more of RAM. They claim that it took longer to restore the memory state from disk than to just do a normal boot. I disagree since it takes a long time to spin up all your apps, virtual machines, and start being productive. I wonder if they discovered some technical issue that is what is causing the issues on Macs.