Why does Firefox cause high-CPU-usage "spikes" every few seconds?
Solution 1:
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.
Solution 2:
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.