Zit Seng's Blog

A Singaporean's technology and lifestyle blog

Repairing Lion

Much as I enjoy working with Mac OS X, and think it is so much more fun than Windows XP, Vista, or 7, there are some issues with it that I’m having. The chief problem is that, from time to time, my MacBook Pro (MBP) does not properly wake up from sleep. When I try to wake up my MBP by opening the lid, I either get: 1) a blank black screen with just the mouse pointer, or 2) a beach ball on the lock screen with the unlock password prompt. There doesn’t seem to be anyway for me to get past that to my desktop.

Except, of course, to do a reset. This has been happening for a long while. This problem usually doesn’t happen very often, like lesser than once a month. But there are other times when it can happen so often that it gets very irritating. Yesterday, for example, it hit me three times. I was sufficiently annoyed to consider reinstalling Lion.

I’ve been using Macs, migrating my stuffs to each successive hardware that I upgrade to, since like 2003 or 2004. I’ve been thinking if I’ve accumulated too much cruft in the last 7 to 8 years that is starting to overwhelm Mac OS X. This problem did not just start with Lion. I think I can remember it happening with Leopard… which is 2 version of Mac OS X ago. Each time there is a software update, I cross my fingers and hope this problem will go away. When I upgraded Mac OS X through new versions, I did the same. Sometimes it seems like the problem had gone away… but it eventually comes back.

Thanks to SSD, rebooting my MBP is fast… so rebooting is just a minor inconvenience. But, computers are supposed to work for you, not cause inconveniences, not even minor inconveniences.

So, anyway, I’ve researched and found several useful bits of information about how to reset Macs. They don’t really fix my problem (since, after all, they eventually still come back…), but it does give the satisfaction that you’re clearing some cruft out of the computer.

First, here’s how to reset the System Management Controller. This is for MBPs that have built-in batteries (i.e. batteries that are not meant to be user replaceable).

  1. Shutdown the Mac.
  2. Remove the power cord, wait 5 seconds.
  3. Reconnect the power cord.
  4. Simultaneously press Ctrl, Option, Shift, and the power button. Just normal press and release. No need to hold it there.
  5. Wait a few moments. You might notice the LED indicator on the magsafe connector change colour.
  6. Press the power button to boot up the Mac normally.

Another thing that can be reset is the PRAM (or NVRAM). Here’s how:

  1. Shutdown the Mac.
  2. Press the power button to boot up normally.
  3. Immediately press Command, Option, P and R keys simultaneously and hold it there until the Mac sounds a chime tone.
  4. Release the keys.
  5. The Mac will boot up normally.

One of the new features starting with Lion is that Mac OS X saves application state when you quit them so that you can resume from where you left off. I’ve found that some applications, like Preview, seem to take longer to start up over time. At least for me, removing the saved application state seems to restore its original performance. It might work for other apps too. The saved application states are stored in:

~/Library/Saved Application State/

Each application will have one subdirectory in there. You can remove all of them with a command like:

$ rm -rf ~/Library/Saved\ Application\ State/*

(Backslash needed to escape the spaces in the directory name.)

To permanently stop saving the application state:

  1. Open System Preferences.
  2. Click on General.
  3. Look for “Restore windows when quitting and re-opening apps”, under the “Number of recent items” area, and uncheck that box.

If you just want to disable the saved application state for some specific apps, check out OS X Daily’s post.

There’s also other cruft you could get rid of:

  • ~/Library/Preferences/ByHost/*windowserver*
  • All the *.lockfile under ~/Library

In fact, if you try to poke around ~/Library, there are plenty of things that look like they are random cruft left behind from really poor housekeeping. For example, I have like 156 files named like com.apple.iTunes.plist.??????? under ~/Library/Preferences, which look like temporary files. There are plenty of other similar *.plist.??????? in there too. I removed all of them.

Finally, I felt that my SSD wasn’t running as fast as it used to be. I have the OCZ Vertex 2 160GB SSD, which supposedly has its own internal garbage collection. No need for TRIM support from the OS. The trick, it seems, to get garbage collection to go about collecting garbage is to have the disk powered up but left idle. That means, to keep the Mac running but not using the disk.

The way I do this is to reboot the Mac into the login screen, but don’t login. Leave it in the login screen (make sure to disable sleep, etc) overnight. The next day, it seems like the SSD does perform better… it really does, even though I didn’t actually run any objective disk benchmark to confirm.

Oh yes, I must say this again: the SSD is about the best upgrade you can get for any notebook.

Leave a Reply

Your email address will not be published. Required fields are marked *

View Comment Policy