Posts tagged Troubleshooting

Does Your Mac Get Slow After a Couple Hours of Use? It’s Probably Safari’s Fault

In the past couple of months, I started noticing that my MacBook Pro would slow down to almost unusable speeds after a couple of hours of use. This was troubling because my computer was loaded with 4GB of RAM and a 2.66 GHz i7 processor, so it should be plenty fast. Anyway, when I would notice my Mac running extremely slowly, I would generally exit all the apps I was running, and restart the computer. This would solve the problem temporarily, but after a couple more hours of use, my Mac would be running very slowly again.

I started investigating this and what I found was that if you have Mac OS X Snow Leopard or Lion, then Safari is most likely the reason why your system is running slowly. I discovered this by opening up Activity Monitor and finding that two processes, Safari and Safari Web Content, were hogging most of the CPU capacity, and the memory usage would climb significantly the longer you had Safari open.

Once I decided Safari was to blame, I did some Google searches on the topic and found that I was not alone. This thread on Apple’s support forum has hundreds of comments from users who have discovered the same thing. Some of the users note that keeping Gmail open in Safari makes the problem even worse.

Since I could not find a fix that would make Safari stop leaking memory and hogging processor power, I switched my default browser over to Google Chrome and my system is running lightning fast again. I will not be using Safari again until Apple fixes this.

How to stop Safari 5 from unexpectedly reloading pages


Annoyed by Safari 5.1’s tendency to spontaneously reload pages when you didn’t ask it to? There’s a workaround for it, but it introduces a few problems of its own. Some Safari extensions will not work, and some of the new gestures won’t work either.

If you don’t rely on any extensions, and you can live without the new gestures (specifically, the new two-finger back/forward, smooth pinch-to-zoom, and the iOS-style smart-zoom), here’s how to fix it.

First, you need to enable the Debug menu in Safari, if you haven’t done so already. Copy the following line and paste it into a Terminal window, then quit and re-open Safari.

defaults write IncludeInternalDebugMenu 1

You should now see a Debug menu in Safari, to the right of the Help menu (not to be confused with the Develop menu). In this menu, disable “Use Multi-process Windows” by selecting it (when it’s disabled, it will no longer have a checkmark next to it).

Close all Safari windows. From this point, any new windows or tabs you create will have a title that ends in [SP] (“single process”). Safari will not reload any tabs in a single-process window. You can confirm this by selecting “Crash Web Process” from the Debug menu; this would normally trigger the tab-reloading behavior, but with “Use Multi-process Windows” disabled, this will no longer happen.

That’s it. If you end up missing your extensions or gestures, just re-enable “Use Multi-process Windows”.

If you use 1Password…

If you happen to use 1Password, you’ll notice it’s unable to automatically fill in your passwords in single-process windows. Fortunately, the 1Password pop-up (accessible via the [1P] toolbar button) still works, and still allows you to copy passwords and paste them yourself.

Some extensions will not work

Some extensions don’t work properly with single-process windows. In particular, extensions that interact with page content (such as ad and plugin blockers) don’t seem to work. If you find some of your extensions aren’t working properly, you might be able to install an older version of the extension that’s intended for Safari 5.0. I haven’t tried that, but if there are any extensions you can’t live without, it might be worth a shot.

Update: added info about missing gestures.

Update: I mistakenly referred to older versions of Safari extensions as being for Safari 4. Extensions were introduced in Safari 5, and it’s Safari 5.1 that moved to the new multi-process architecture of WebKit2 — i.e. this article actually only pertains to Safari 5.1. On further inspection, I’m not sure the reasoning I offered for extensions not working in single-process windows was accurate, so I’ve removed it.

(You can stop reading here, unless you’re interested in the nerdy details…)

What’s going on here?

So what is a “multi-process window” anyway?

One of the new features in Safari 5.1 is a major new version of the underlying engine — WebKit2. Under WebKit2’s new process architecture, Safari consists of two separate processes — the “UI process” (the Safari application itself, including the address bar, toolbar, bookmarks bar, menus, etc.), and the “web process” (an independent process that loads and displays actual web pages).

Apart from other goals, the purpose of this is to provide some measure of crash protection. While it does prevent the entire Safari application from crashing (at least as far as I’ve seen), it doesn’t protect you from losing anything you’ve typed into text fields in web pages. All web content is handled by a single web process, so if any page malfunctions and causes the web process to crash, all open tabs will be reloaded, and anything you had typed into any of those pages will be lost. Furthermore, any downloads that were in progress will also be halted; you might be able to resume some downloads, but many will have to be started over. This can be very frustrating when downloading large files.

For that reason, the benefits of the new multi-process architecture are somewhat dubious, at least until Apple manages to address the issue of spontaneously reloading tabs (assuming it’s even possible to prevent this behavior without redesigning the overall architecture of WebKit again).

Check out the WebKit2 page on the official WebKit wiki for more details.

Update 5/21/2012: It seems to me that Apple has fixed this auto-reloading bug, but Safari is still flawed. I wrote a post about why Safari is slowing down your Mac.