Firefox Memory Usage FQA
Contents [Skip]
-
About This FQA
-
Themes, Extensions, Plugins
-
Firefox Tweaks
-
Other Issues
-
Bugs & Fixes
-
Known Leaky Extensions
- How Can I Help?
- Things That are Not Leaks
- Translations
About This FQA
Introduction
Firefox memory usage has been quite a hot topic since the release of Firefox 1.5. This FQA is designed to provide you with tips on how to minimise the amount of memory Firefox uses, information on what is known to cause memory leaks in Firefox, what is and isn't a memory leak, progress on the fixing of memory leaks and ways you can help.
FQA Notes
FQA stands for "Frequently Questioned Answers", which is very fitting for this subject...
Acknowledgements
The information and solutions in this thread have been sourced from various users and threads, and the MozillaZine knowledge base.
Special thanks to: Jesse Ruderman Steve England Fellow old timer schapel
Themes, Extensions, Plugins
Themes & Extensions
Themes and extensions can cause memory usage to increase significantly. Try running Firefox in Safe Mode to see if it is a theme or extension causing your problem. See also Known Leaky Extensions.
Adblock
Using old versions of Adblock with Firefox 1.5 is a bad idea in general, and has been reported to cause increases in memory usage. Firefox 1.5 users should use AdBlock Plus or upgrade to Adblock 0.5.3.042. If you have not installed Firefox 1.5 yet, uninstall Adblock and restart Firefox twice before installing Firefox 1.5.
Fasterfox
The Fasterfox extension has a feature that enables prefetching of all static links in the page you are viewing ("Enhanced Prefetching"). This is off by default. Whilst switching this on can decrease the amount of time taken to load pages (because it fetches them before you attempt to view them), it will also increase memory usage.
Firefox Preloader
Using the Firefox Preloader will increase memory usage. Disabling it if you do not need it will save memory. (Yes, I know this behaviour is by design...)
Plugins
Some browser plugins, particularly Adobe Reader and Java, can use large amounts of memory. Since plugins are not unloaded after use, restarting Firefox can help.
Java
Java users should update to Java Runtime Environment 1.5.0_07. Turning off the Java Console using the Java Control Panel may also reduce memory usage.
Adobe Reader
Adobe Reader 6.0, and to a lesser extent 7.0, can use large amounts of memory. Upgrading to Adobe Reader 7.0.8 can help reduce memory usage. Disabling unused Adobe Reader plugins can help too.
Firefox Tweaks
Firefox Memory Cache
By default, Firefox does not use a fixed size memory cache - it uses a percentage of system memory. Setting a fixed size memory cache can often reduce memory usage - 4 or 8MB is sufficient in most instances. To set a fixed size memory cache, add the following pref using about:config:
browser.cache.memory.capacity
This is an integer pref, and can be set to the size you want the cache to be (in kilobytes).
There has been some debate about how Firefox sets the memory cache size. See bug 105344, bug 204164 and bug 296538 for various discussion about this issue.
You can also disable the Firefox memory cache completely, however this is not recommended. To do this set the following pref to false using about:config:
browser.cache.memory.enable
Memory Usage Upon Minimize
There is a pref that enables trimming Firefox memory usage when you minimize all Firefox windows. This pref is for Windows only. To enable it, set the following pref to true using about:config:
config.trim_on_minimize
Fast Back/Forward
Firefox 1.5 has a new fast back/forward feature (bfcache) that vastly reduces the amount of time taken to display pages when the back/forward buttons are used. This adds to memory usage. To disable this, set the following pref to 0 using about:config:
browser.sessionhistory.max_total_viewers
You can also control the number of pages stored instead of disabling it entirely, this is documented in the MozillaZine Knowledge Base. Note that the amount of memory used will vary according to the size and content of pages.
Browser History
Setting the browser history to extremely large values will increase memory usage. Keeping the history to a reasonable level is a good idea for this reason.
Download Manager
Clearing out the list of downloaded files every so often will reduce memory usage.
Other Issues
JavaScript
Pages with lots of (or bad) JavaScript can increase memory usage. Using NoScript to control when sites can use JavaScript can help in this situation.
Profile Corruption
Profile corruption can cause all sorts of strange behaviour, including increasing memory usage. If you suspect your profile is corrupted, or none of the other suggestions work, you can try creating a new profile.
Bugs & Fixes
Fixed in Firefox 1.5.0.5
- Bug 325984 - DOMWindow leak with <col onload>
Note: Firefox 1.5.0.5 has not been released at this stage.
Fixed in Firefox 1.5.0.4
- Bug 283565 - Improper use of Realloc (mlk/crash) and silly return value for OOM
- Bug 289897 - huge memory leak when klipper is running
- Bug 330624 - accessibility code (when accessibility enabled) holds on to DOM nodes until shutdown
- Bug 333134 - Accessibility still leaking when AT used
Fixed in Firefox 1.5.0.3
Firefox 1.5.0.3 is a security only update, with no memory leak bugs fixed.
Fixed in Firefox 1.5.0.2
- Bug 321283 - Using Find causes documents to leak
- Bug 323532 - Leak when using history autocomplete
- Bug 323377 - Lots of leaks in nsInternetSearchService
Fixed in Firefox 1.5.0.1
- Bug 316775 - leak when selecting
- Bug 317478 - leaks due to global scope polluter being removed from not enough (?) prototype chains
Fixed on Gecko 1.8 Branch
- Bug 168411 - Move bookmarks transactions into a JS service (adding a bookmark leaks the Add Bookmark dialog)
- Bug 206520 - XMLHttpRequest leaks memory if send() not called and event listeners set
- Bug 283565 - Improper use of Realloc (mlk/crash) and silly return value for OOM
- Bug 289689 - Memory leak: nsDebugImpl::Assertion, Create Process
- Bug 289897 - huge memory leak when klipper is running
- Bug 316775 - leak when selecting
- Bug 317478 - leaks due to global scope polluter being removed from not enough (?) prototype chains
- Bug 319980 - javascript garbage collector not run when supposed to, leading to "memory leak"
- Bug 323454 - [FIX]Don't leak the channel and XMLHttpRequest object if AsyncOpen fails
- Bug 321283 - Using Find causes documents to leak
- Bug 323532 - Leak when using history autocomplete
- Bug 323377 - Lots of leaks in nsInternetSearchService
- Bug 325984 - DOMWindow leak with <col onload>
- Bug 330624 - accessibility code (when accessibility enabled) holds on to DOM nodes until shutdown
- Bug 330780 - [ATK only] global nsAppRootAccessible is not released on shutdown
- Bug 330878 - Firefox leaks the update.xml document when it checks for updates
- Bug 333134 - Accessibility still leaking when AT used
- Bug 333764 - Livemark Service leaking nsRDFResource and RDFServiceImpl references
- Bug 334105 - [FIX]ASSERTION: Bogus: '!mHead' (nsLineBox.cpp#916 - nsFloatCacheFreeList::Append)
- Bug 336922 - nsAnnotationService leaks
- Bug 337044 - Search engine Manager leaks an observer when canceled
- Bug 341301 - 1.8 branch firefox leaks like a sieve
Fixes on the Gecko 1.8 branch will be included in future Firefox releases from that branch, such as Firefox 2.0. These fixes may also be included in future Firefox 1.5.x releases.
Note: Some of the bugs in this list apply to new functionality not found in earlier releases, and are mainly of interest to people testing nightly builds.
Fixed on Trunk
- Bug 168411 - Move bookmarks transactions into a JS service (adding a bookmark leaks the Add Bookmark dialog)
- Bug 206520 - XMLHttpRequest leaks memory if send() not called and event listeners set
- Bug 241518 - calling addEventListener with a closure holding a content node leaks the document
- Bug 283565 - Improper use of Realloc (mlk/crash) and silly return value for OOM
- Bug 289689 - Memory leak: nsDebugImpl::Assertion, Create Process
- Bug 289897 - huge memory leak when klipper is running
- Bug 315708 - Should release found link and current window object from nsTypeAheadFind.cpp
- Bug 315951 - unknown content type dialog leaks domwindow
- Bug 316775 - leak when selecting
- Bug 317478 - leaks due to global scope polluter being removed from not enough (?) prototype chains
- Bug 319980 - javascript garbage collector not run when supposed to, leading to "memory leak"
- Bug 320211 - parser-related leak when loading DOM inspector in Firefox
- Bug 321040 - observer service should remove null weak references from observer lists when enumerating
- Bug 321283 - using Find causes documents to leak
- Bug 323377 - Lots of leaks in nsInternetSearchService
- Bug 323441 - Memory leak if a site sets location and then document.writes (e.g. when visiting www.economist.com)
- Bug 323454 - [FIX]Don't leak the channel and XMLHttpRequest object if AsyncOpen fails
- Bug 323532 - [FIX] Leak when using history autocomplete
- Bug 323534 - createTreeWalker can cause leaks due to cycles created by closures
- Bug 325305 - minor memory leak in CERT_FindCertByNameString
- Bug 325984 - DOMWindow leak with <col onload>
- Bug 326491 - Leaked observer service leaks things on shutdown
- Bug 327670 - Memory leak in MarkOutOfFlowChild
- Bug 329071 - Leaking an nsZipFind if jar enumerator allocation fails
- Bug 330624 - accessibility code (when accessibility enabled) holds on to DOM nodes until shutdown
- Bug 330649 - leak nsContentShellInfo objects
- Bug 330780 - [ATK only] global nsAppRootAccessible is not released on shutdown
- Bug 330878 - Firefox leaks the update.xml document when it checks for updates
- Bug 331706 - Leak when scrolling
- Bug 333134 - Accessibility still leaking when AT used
- Bug 333296 - nsCharsetConverterManager::GetList leaks array if it can't get catman
- Bug 333298 - nsTextToSubURI::UnEscapeAndConvert leaks pBuf if decoder->Convert fails
- Bug 333313 - oom mlk in InternetSearchDataSource::BeginSearchRequest
- Bug 333354 - mlk on early return
- Bug 333672 - Leaking imgSurf in nsCanvasRenderingContext2D::DrawImage
- Bug 333674 - We leak oldVal on OOM in nsUint32ToContentHashEntry::PutContent
- Bug 333733 - Could leak attr in nsFrameUtil::Tag::ReadAttrs
- Bug 333764 - Livemark Service leaking nsRDFResource and RDFServiceImpl references
- Bug 333796 - Could potentially leak ctx in nsSVGCairoGlyphGeometry::GetBoundingBox
- Bug 334105 - [FIX]ASSERTION: Bogus: '!mHead' (nsLineBox.cpp#916 - nsFloatCacheFreeList::Append)
- Bug 334421 - Shutdown leak of mEvictionQ entries
- Bug 334898 - jsj_ResolveExplicitMethod leaks arg_start if convert_java_method_arg_signatures_to_hr_strin fails
- Bug 335785 - wrapper reparenting leak on gmail
- Bug 336475 - Coverity NSC_VerifyInit error paths don't free "info"
- Bug 336477 - Coverity CERT_UncacheCRL variable named "returned" is not freed if !removed
- Bug 336922 - nsAnnotationService leaks
- Bug 336961 - DOM Inspector leaks (dom.js)
- Bug 337029 - [mlk] bookmark properties dialog leaks a microsummaryObserver when canceled
- Bug 337044 - Search engine Manager leaks an observer when canceled
- Bug 337110 - Coverity OOM Crash and memory leak [@ PK11_CreatePBEParams]
- Bug 338003 - imgCache::Init leaks imgCache if do_GetService fails
- Bug 338075 - CID 538, RESOURCE_LEAK
- Bug 339477 - tabbrowser.xml's observer destructor never gets called, leaking mTabClipWidth at shutdown
- Bug 339913 - Coverity OOM leak in sec_asn1d_add_to_subitems
- Bug 339914 - Coverity leak in NSS_CMSEncoder_Start error paths
- Bug 339916 - Coverity 464, leak after OOM in CERT_DistNamesFromNicknames
- Bug 339919 - Coverity 905, leak in CERT_GetCertNicknames
The trunk is where bleeding edge Mozilla development takes place. Fixes on the trunk will be included in Firefox 3.0, and may be included in future Firefox 1.5.x and 2.0 releases.
Note: Some of the bugs in this list apply to new functionality not found in earlier releases, and are mainly of interest to people testing nightly builds.
Known Leaky Extensions
Fixed
- Adblock 0.5.3.042
- AdBlock Plus 0.7 [Mozdev Bug 13704]
- ForecastFox 0.9.2 [Bug 326258]
- NoScript 1.1.3.9 [Bug 324817]
- Search Keys 0.7.3 [Changelog]
- The combination of Flashgot & Adblock Filterset.G Updater is known to cause leaks [Bug 324586], FlashGot 0.5.9.995 fixes this
- Thumbs 0.6.2 [Changelog]
Not Fixed
- IE Tab 1.0.7 [Bug 324793]
- Session Saver 0.2.1.031 [Bug 324864]
How Can I Help?
Memory Leak Detection Tool
David Baron recently wrote a tool that testers can use to help reduce memory leaks in Firefox. It tracks three types of objects (documents, docshells, and domwindows), and attempts to report the URLs associated with the leaks that are detected. For more information, see the following weblog entries:
[Please file good memory leak bugs (David Baron)]
[Please file good memory leak bugs, Part 2 (David Baron)]
[Firefox memory leak detection tool (Jesse Ruderman)]
Leak Monitor Extension
David Baron has written an extension to detect a specific type of memory leak in Firefox. It detects when JavaScript objects in the chrome or Web page are still held by native code after the window is closed. The information provided by this extension can be used for filing bugs, however reading the information on the extension page is essential before using it for this purpose.
[More Information]
[Install Leak Monitor]
Things That are Not Leaks
Firefox Memory Usage Doesn't Always Go Down
This is generally not an issue, and does not represent a memory leak. Why? When Firefox is finished with memory, it releases it to its heap. However, operating system reports this memory as being in use, even though Firefox is not using it for anything. A common symptom of this is the amount of memory used by Firefox going up, but not coming down - instead staying constant.
Large Images are Not Compressed
When Firefox displays images it decompresses them. When combined with memory cache and Fast Back/Forward (bfcache), this can cause pages with large or many images to make the browser use a lot of memory. This is not a leak, because when the memory is not required it gets released to the heap.