9

When I start Firefox, I have no problems for a while, but after a couple of days, CPU spikes start to occur. During a spike, Firefox freezes and then stops. Spikes occur every seven to ten seconds, and each spike lasts for two to three seconds. If I am typing when a spike occurs, characters output only after the spike. I initially thought this problem was because of Flash, so I disabled it, but the problem still occurs.

Also, Firefox's memory usage increases to over 600 MB after several days.

The list of Firefox plugins and extensions I use is available here.

4
  • 6
    Firefox has always had memory leaks, that part is normal.
    – user1931
    Commented May 27, 2011 at 15:42
  • The symptom is tracked in bug 490122. I don't seem to experience these in Firefox 4+ anymore - thankfully.
    – RomanSt
    Commented Sep 25, 2011 at 16:38
  • 1
    And every new version they promise they've fixed it! google.com.au/… Commented Jan 13, 2013 at 6:06
  • 1
    @MatthewLock What about this? It seems only users on Reddit feel like this gets addressed every version...
    – Daniel Beck
    Commented Jan 13, 2013 at 11:54

5 Answers 5

9

I suspect it is either the Garbage Collector or the Cycle Collector.

In about:config change javascript.options.mem.log to true. Now notices about GC and CC should be available in the Error console (Crtl+Shift+J) If their timing and duration matcher the freezing, then this is your problem.

When I had this problem I fixed it by blowing away my Firefox profile and creating a new one from scratch. The Firefox profiles have a tendency to gather a lot of crud over time.

Even this is not a prefect solution. If you open a lot of tabs in Firefox (100+) or lots of extensions and leave Firefox running for days on end it will inevitably slow down. You will need to restart Firefox every once in a while.

If you are like me and have a tendency gather a large collection of tabs you need get around to dealing with at some point another trick I use is to set browser.sessionstore.max_concurrent_tabs to 0. This will stop Firefox from loading all the tabs of your session when starting. It will instead load them when you switch to them. I find this, plus the occasional restart of Firefox, greatly reduces the load of having a great many tabs.

5
  • 2
    There is Firefox plugin called BarTab. I assume it does same thing about browser.sessionstore.max_concurrent_tabs
    – Boris_yo
    Commented May 27, 2011 at 14:24
  • 1
    Yes, although I believe it is not updated for Firefox 4.
    – Mr Alpha
    Commented May 27, 2011 at 15:25
  • 1
    There's a Bugzilla entry on Firefox GC / CC becoming unusually slow.
    – RomanSt
    Commented Sep 25, 2011 at 16:37
  • 1
    "max_concurrent_tabs" does not appear to be in Firefox 40 (2015-08). Commented Aug 16, 2015 at 21:06
  • I think the current equivalent of max_concurrent_tabs is the setting in preferences under "General" called "Don't load tabs until selected".
    – miyalys
    Commented Sep 19, 2015 at 11:52
9

In about:config, set browser.sessionstore.interval to a large number (it should be 10,000 or 15,000; set it to about 600,000).

Basically, this is the number of milliseconds between times that Firefox updates your "saved session". If you have many tabs open, or a long browsing history (or, as is often the case with me, both), this can be writing a ridiculous amount of data to the sessionstore.js file every 10 or 15 seconds, which can cause Flash videos to freeze briefly or even render your entire computer frozen every few minutes.

Setting this value to a large number has the disadvantage that if Firefox crashes, you lose your last few minutes of browsing history when you try to restore. That's a small price to pay in my opinion.

Your CPU spikes should become much less frequent.

3
  • 2
    I have Session Manager plugin installed. It also saves sessions allowing better management and customization. What if Firefox and this plugin both update sessions causing high CPU usage and crashes? Is there a way to disable Firefox's session update function and keep Session Manager?
    – Boris_yo
    Commented Mar 13, 2012 at 12:07
  • 1
    In Firefox 40, it appears to save it in file "\sessionstore-backups\recovery.js" (note: in sub folder "sessionstore-backups") instead of "sessionstore.js" (and the previous version in "\sessionstore-backups\recovery.js"). Commented Aug 16, 2015 at 21:18
  • 1
    OK, this seems to have changed with Firefox 33 (2014-06), not Firefox 40. Commented Aug 16, 2015 at 22:01
4

It won't fix memory leaks per se. But enabling "Don't load tabs until selected" will at least not load the tabs until you click on them after a restart, which keeps memory way down.

I also found using CCleaner to clean the Firefox "Session" helped a bit. Back up all your open tabs first as it removes the session recovery information. Before running CCleaner my sessionstore.js file was about 800 KB, but afterwards it's down to about 6 KB.

More information about sessionstore can be found in Solved: Firefox Freezes Every 10 Seconds, Scrolling is Jumpy.

Uninstalling Flashblock fixed my high CPU issues with Firefox. Perhaps Flashblock and Adblock Plus or some other extension don't get along?

Life's too short to mess around with Firefox. I just exported my bookmarks, and uninstalled Firefox, then deleted all the Firefox folders on the machine, and then reinstalled Firefox from scratch, and restored the bookmarks. Now it runs faster than Google Chrome with a totally new install.

2

It is very difficult to tell. Is it just general use that causes it, or are you accessing a specific site? (We had a problem where a browser gained memory over time because of a memory leak in jQuery).

Assuming you're using a Microsoft OS, you could try using Microsoft's Process Monitor tool. It spits out shed loads of messages, but you should be able to narrow them to the interval where the 'freeze' occurred, and maybe see what process is doing the blocking.

8
  • jQuery can have a memory leak? Hrmmmmm
    – Jeff F.
    Commented May 27, 2011 at 13:38
  • 1
    It can happen. See this list of jQuery bug tickets: bugs.jquery.com/search?q=leak&go=&ticket=on. We encountered because we were constantly hitting a single page (through an AJAX request triggered at an interval) that precipitated a fairly large leak. Commented May 27, 2011 at 13:47
  • 1
    Sounds more like a browser issue and less of a jQuary issue is what I'm saying since it can't run but in a browser(well for most cases anyhow) :) (if while(1==1){} crashes a browser I blame the browser :P)
    – Jeff F.
    Commented May 27, 2011 at 13:53
  • 1
    While you are correct in asserting that the browser is at fault (some of the bugs on the above link were related to IE's failure to properly handle circular references), there are steps that a developer can take in their JS code to ameliorate these issues. In C/C++ you have to clean up memory you have manually allocated as there is no GC for you to do this. If you don't is this a fault in your code, or the runtime? I would argue that not accounting for the limitations of your environment can be considered a bug on your behalf, and it looks like that's exactly how the jQuery team view it too. Commented May 27, 2011 at 14:02
  • 1
    Well this ended up in a silly argument :P. JavaScript is not code, it is script; script runs within another program. A poorly written program runs on it's own it requires proper writing because of this. A good program that accepts script will prevent it from breaking itself. Hence why if you check bugzilla, you'll see what are considered bugs relating to poorly written JavaScript causing Firefox to crash. This topic is pretty opinionated though, so I'll leave it at that! (The first comment was more of a joke since the browser leaks not jQuery)
    – Jeff F.
    Commented May 27, 2011 at 14:08
0

If you aren't already doing so, you might try upgrading to the latest Firefox. They've worked hard to reduce those memory leaks.

1
  • I always upgraded and problem stayed. I prefer to live with Firefox 3.6.17
    – Boris_yo
    Commented May 30, 2011 at 13:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .