Monday, April 20, 2009

How to Stop Firefox Becoming an Uncontrollable Memory Fiend

Seeing as this blog was just sat here gathering dust, I thought I might as well put it to some use, rather than have it act as some kind of archive for my petty grievances with the rest of the world.

Recently, I've being having something of a 'mare with Firefox.

Namely, it's been taking a dog's age to start up and even longer to quit, while in between its consumption of my computer's memory has been something akin to a fat man at an all-you-can-eat buffet.

A fat man who quickly finishes all the food, and starts chomping on the fixtures and fittings.

In fact, more often than not I'm forced to shut it down manually from Task Manager, rather than experience the life force slowly ebb out of me waiting for it to end.

It's made my favourite browser almost unusable, and at the time of typing, I can't honestly say that it's entirely sorted, but I have discovered some extremely useful tricks that I thought I should share.

Check Your Add-ons

Boring, I know, and every guide I've read to try and solve my problem (I've read a lot) mentions this, but it's worth doing.

  1. Firstly, check for updates to Firefox (Help -> Check for Updates). In the event that this does not magically solve the problem, close down Firefox in start it in Safe Mode (select it from the Programs menu), making sure to select the option that disables all extensions.
  2. Use it for a bit and have a look in Task Manager (Ctrl+Alt+Delete) under the 'Processes' tab to see if you're still getting excessive memory usage, and whether Firefox is still taking an unusually long time to completely close.
  3. If you're still getting problems in this state, you might possibly be better off completely reinstalling Firefox altogether, but make a backup of your Firefox profile first, as you may be able to save things like bookmarks, history and other preferences etc.

    It's usually stored in C:\Documents and Settings\username\Application Data\Mozilla\Firefox\Profiles

    In truth, performance problems are usually caused by some kind of conflict with extensions, so you should find you don't have many problems using Firefox in Safe Mode.

  4. In Firefox, go to Tools > Add-ons and look under 'Extensions'. Click the 'Find Updates' button, install any new versions if found, then restart Firefox.
  5. Go here: http://kb.mozillazine.org/Problematic_extensions and see if any of the add-ons you use are in the list. If they are, follow the suggestions for each one, usually involving replacing them with a similar one or uninstalling them altogether.

    Frankly, no matter how useful an add-on may be, if it's compromising the overall performance of your browser to the point of near-unusability, you're better off without it.

Pimp Your Preferences

Here's a fantastic tip which is so good, I can't believe it isn't incorporated into Firefox by default.

  1. Go to Firefox's address bar at the top and type in about:config, then press Enter.
  2. Click the 'I'll be careful, I promise!' button and then right click on the page and select New -> Boolean.
  3. In the pop-up, enter config.trim_on_minimize and press Enter.
  4. Select True and then press Enter.
  5. Restart Firefox.

Now, whenever you minimize Firefox, its memory usage sort of 'resets', and while it does build up again, usually it should top off at a much more manageable level.

Major 'props' to the techgurls blog for that one.

Greedy Google Toolbar

Google Toolbar can be very useful indeed, what with all the customisable buttons and that, but recently it seems to have developed something of a memory habit akin to a junkie needing a regular fix.

It's time for an intervention.

Navigate to your Firefox profile folder, (usually C:\Documents and Settings\username\Application Data\Mozilla\Firefox\Profiles) and look for a file named places.sqlite.

If this file seems ridiculously large (mine was about 180 MB; even for a heavy user of Firefox it really should be a fraction of that), then Google Toolbar may be to blame.

You see, it rather over-zealously makes a thumbnail of every page you visit, just in case that page becomes one of your most frequently visited pages, and it needs to have an image of it for use in the 'new tab' page.

You may never have even seen this page, but regardless I would say this feature is certainly less than essential. If it's crippling your browser though, then it really needs to be turned off.

  1. Click on the little spanner (wrench for our American friends) logo at the right of Google Toolbar, or simply right click in the toolbar and select 'Google Toolbar Options'.
  2. Under the 'Search' heading, uncheck the option that says 'Enable the Google new tab page' then click the 'Save' button. Close down Firefox.
  3. Make a copy of your Firefox profile folder and save it somewhere like the Desktop. Y'know, just in case.
  4. Download SQLite Database Browser and extract the contents.
  5. Start the application inside the folder, and in the window click on the yellow folder icon at the top left. Navigate to places.sqlite in your Firefox profile folder and open it.
  6. Click on the tab labelled 'Browse Data', then click the drop-down box beneath and select 'moz-anno_attributes'. Make a note of the id number for google-toolbar/thumbnail and google-toolbar/thumbnail-score. (For me it was 10 and 11 respectively).
  7. Click the Execute SQL tab and in the SQL string box paste:

    delete from moz_annos where anno_attribute_id = 10; // 10 = 'google-toolbar/thumbnail' vacuum;

    Of course, if the id number is different for you change it accordingly.

  8. Click the 'Execute query' button.
  9. Repeat this for the other attribute:

    delete from moz_annos where anno_attribute_id = 11; // 11 = 'google-toolbar/thumbnail-score' vacuum;

  10. Click File -> Compact Database.

Now, have a look and see how big places.sqlite is in your Firefox profile folder. If this has worked anything like it did for me, it should be at least a tenth of the size.

Thanks to the peeps on this thread for the technical nerdery on this one.

Right, if your Firefox browser doesn't work better after all of that, I will personally send you $1,000 dollars.*

*No money will be sent.

2 comments:

Anonymous said...

All of this database work can be done in a less error-prone way in one singe statement:

DELETE FROM moz_annos WHERE anno_attribute_id IN (
SELECT id FROM moz_anno_attributes WHERE name IN('google-toolbar/thumbnail', 'google-toolbar/thumbnail-score')
)

ScotchJohn said...

Neither of the SQL commands worked, but manual selection of the relevant rows did - what a relief, reduced from nearly 10 MB to 3.8 MB