As I mentioned previously, my workhorse laptop was stolen late December, 2006. Since then I’ve been using a much older laptop circa 1988. Okay, it’s not that old, but it’s a Pentium 4 with only 500 MB of RAM … and it turns out, my Firefox browser occasionally likes to suck up about 3-400 MB of that RAM in one sitting.
Of course, that might have something to do with all 47 of my favorite extensions (“My Firefox on crack: the best extensions I could find“).
Every time I install Firefox on a new machine, I wind up tweaking its registry settings to improve its page-load time and network connections to give me a better browsing experience. This time I needed to do the same thing, but also minimize some of the RAM I’m using. While doing the research for my tweaks, I thought I’d share my results with you in case you’re interested and brave enough to muddle around in the Firefox about:config settings. Also, I wanted to save my notes on my blog so I won’t have to trawl the Net again the next time ’round.
If you do make any of these changes to your Firefox installation, please don’t contact me for support. I’m not a techie, I only played one at my last job.
First things first, you can easily reduce considerable memory overhead by uninstalling all your extensions. Okay, so maybe you’re addicted to all your cool tools. I know I am. But there are some you should be wary of anyhow, as they’re known to “leak” memory — meaning the longer you have Firefox open the more memory they consume. There are a few lists describing the usual suspects, but you should know that extension developers are usually trying to beat a bad rap, so keep checking in for updates to the extension: Known Leaky Extensions.
Forget your history
Next, reduce the number of days your Firefox tracks your browsing. The more you track, the more memory Firefox apparently uses. Change this by going to Tools » Options » Privacy » History. I set my history to three days.
Modify your configuration
Go to your Firefox location bar and type about:config and hit Enter. You’ll get a crazy table of techie-looking names on the left and numbers and options on the right. This is the complete output of all your Firefox configuration settings. Depending on what extensions and themes you have installed, yours will look different than mine. To change a configuration item, you only need to doubleclick on the setting you want to change, and a box will pop up with the current setting plugged in. To change it, you just edit the value (if it’s an integer or a string) and click OK. If the setting was “boolean” (meaning either “true” or “false”), double-clicking will automatically change the setting to the opposite value.
Before changing a setting, I usually search for it so I can isolate it from all the other settings around it. To search for a specific value, you just enter the configuration “Preference Name” in the “Filter” bar near the top of the table. Just pasting in the name will isolate the value you’re interested in.
Doing this before changing a value provides a couple of benefits for me: 1) I don’t inadvertently double-click on the wrong neighboring setting by accident. And 2) I find out immediately whether a particular settng actually exists in my configuration or not. Some of the config settings below may not exist in your particular installation, so you’ll have to create them.
To create a config setting, just right click in the table area, select “New” in the context menu that pops up, then select whether you are creating a “String,” “Integer,” or “Boolean” value. A string value is used for things like path names and alphanumeric characters. Integer settings are pure numbers. Boolean settings are either “True” or “False.” (For more info, see “About:Config entries” at the Mozilla Knowledge Base.)
These are the settings I modified to make my Firefox a little faster and more reliable on a machine with little memory. Your mileage may vary. Be sure to check out my resources at the end for more information. I’ve linked each preference name to the Mozilla Knowledge Base for further reading.
Choice about:config settings
Preference name: browser.sessionhistory.max_total_viewers
This is for faster loading of pages via the back and forward buttons on your toolbar. The higher the number, the more pages FF keeps in memory for each tab, and thus the higher the memory usage. One page will on average take 4MB of memory. However, reducing this number will make pages load more slowly when you do use the back and forward arrows because they’ll need to be pulled from your disk cache and re-parsed in memory.
Preference name: config.trim_on_minimize
This setting should force Firefox to dump most of what’s in RAM to disk whenever you minimize it and allows Windows to reclaim the memory for other apps to use. However, some users report spotty success with this, but others claim to be able to get back 90% of their allocated Firefox memory using this hack. (You can view the memory used by applications with a tool like Process Explorer previously from Sysinternals.com but now owned by Microsoft.) Note that if you use this, Firefox may take longer to restore from its minimized state as it has to negotiate for more RAM from Windows to restore itself.
(At the time of this blog entry I have FF open with five tabs. It’s using approximately 104MB of RAM. A few seconds after minimizing, its RAM utilization dropped to 13MB.)
Preference name: content.notify.backoffcount
As Firefox downloads a page it will attempt to render it for display. As it receives more data from the Web, it will move items around on the page to repair rendering until all the data is finally received and the page can be finally re-parsed and fully redrawn. The backoff count limits the number of times FF will redraw the page in memory while downloading content. Setting the number to five, as above, limits FF to redrawing the page six times. Five (max) during downloads (according to the timer intervals set below) and once upon completion.
I set this to five because I have a fast connection and I prefer to get the page drawn quickly even if all the images and stuff haven’t downloaded yet. Every time FF has to redraw the page, it slows down total page load time.
Preference name: content.notify.interval
120,000 microseconds is actually the default. I specified it in case I want to change it later. This is equivalent to redrawing a page (as it downloads) every .12 seconds.
Preference name: content.notify.ontimer
This turns the timer on for the previous two settings.
Preference name: network.http.max-persistent-connections-per-server
Persistent connections are “keep-alive” connections from your browser to the server you’re getting data from. In HTTP 1.1, persistent connections are used to download multiple items via one connection without wasting overhead for one connection per file. On a typical web page you might have 50-100 items that need to be downloaded. Forcing every time to be pulled off a web server with its own connection will slow things down considerably. However, you don’t want too many of these connections per server, since it could clobber a server’s response time. I’ll probably be adjusting this value over time. The default is 2. (Requires that network.http.keep-alive be set to “true.” And if you are using a proxy, see Network.http.max-persistent-connections-per-proxy)
If you’re on dialup, this probably won’t help.
Preference name: network.http.pipelining
Related to the previous setting, this allows Firefox to send multiple requests before any responses are received. The maximum number of requests is set in the following option. This will help page load times on fast connections.
If you’re on dialup, this probably won’t help. (If you are using a proxy, see network.http.proxy.pipelining.)
Preference name: network.http.pipelining.maxrequests
This sets the maximum number of requests that can be sent to a server via pipelining before anything is sent back to the browser. You can choose between 1 to 8.
Preference name: network.http.max-connections
This determines how many total connections Firefox can open to all servers at once. In order to download anything, an HTML file, an image, a video, Firefox has to establish a connection. This setting controls the total maximum number of connections Firefox will establish. Given that many web pages include content from other servers and considering how Firefox extensions also generate their own connections (such as the Google Toolbar), it’s good to have this number higher than the following number, which is a per-server configuration. If you have too many connections open at once, however, you’ll clobber your Internet connection, so make sure you have a good fast pipe before increasing this number.
The downside, of course, is that dialup users won’t benefit from this.
Preference name: network.http.max-connections-per-server
This controls the total number of connections Firefox will establish with a single server. The total max is 255 connections, but I’d caution you to be conservative about this. Rumors persist that some hosts will ban you from their site if you abuse their server. And setting this value too high will clobber your Net connection (again, dialup users, move on), so there’s a “sweet spot” where too high a number slows down your data rate for a given file and too low a number slows down your data rate for a given server. Naturally, this will vary from server to server, so finding the right number for your ISP and the sites you visit will be a matter of trial and error.
Preference name: nglayout.initialpaint.delay
This controls how long (in milliseconds) Firefox will wait before drawing a page on screen. The default is to wait a bit, to make sure some useful data has come down the pipe first. On a fast connection you could set a really low value. On a slower connection (dialup users, beware) you’ll need a higher value. I set mine to zero because FF will wind up repaint the screen within .12 seconds, anyhow, so why wait?
Preference name: plugin.expose_full_path
This doesn’t make anything faster, it just shows you the path to plugins (like the Adobe PDF plugin, etc.) instead of just the name of the plugin.
Preference name: browser.cache.memory.enable
Just make sure this is enabled (set to “true”) so that the following settings work.
Preference name: browser.cache.memory.capacity
This determines how much of your RAM Firefox will use for caching purposes (the cache for pages you’ve recently downloaded, there’s a RAM cache and a disk cache, this just deals with the cache in memory, not on file). Note, I only have 512MB on my current machine, so I’m setting my total cache fairly low. This will probably increase the load time of pages I’ve previously visited (via the back and forward arrows) but it also protects my RAM usage (more important).
Preference name: browser.cache.disk_cache_ssl
Since I am the only one to use this laptop (I, or the thief who steals this machine next!) and since I purge my cache files pretty frequently I’d rather store all my HTML pages on disk rather than in memory. This setting forces Firefox to store secure pages on disk, too, which it normally doesn’t do for security purposes. Note, don’t do this on a public or work computer that others may have access to, since this will expose your secure pages (bank sites, webmail stuff, etc.) to disk browsing. I guess, if you’ve got a nefarious streak in you, you could covertly use this setting to evil ends, but you wouldn’t do that, would you?
Hope this helps! I know it helped me.
Resources used to compile this list:
- element14: Firefox does not have a memory “bug”, but here’s how you improve mem usage
- CyberNetNews: This May Help Your Firefox Memory Leak
- CyberNetNews: Reducing Your Memory Usage In Firefox
- MozillaZine Knowledge Base: Reducing memory usage — Firefox
- PluginDoc: Firefox Memory Usage Frequently Questioned Answers
[tags]about, about-cache, about-config, BlogRodent, Boolean, browser, browser-cache-memory-capacity, browser-cache-memory-enable, config, config-settings, configuration, CyberNetNews, element14, extensions, Firefox, Firefox-extensions, FireFox-plugins, Frequently-Questioned-Answers, history, http-max-connections, http-max-connections-per-server, http-max-persistent-connections-per-proxy, http-pipelining, http-pipelining-maxrequests, http-proxy-pipelining, keep-alive, max-persistent-connections-per-server, max-total-viewers, Mozilla, Mozilla-Knowledge-Base, MozillaZine-Knowledge-Base, network-connections, nglayout-initialpaint-delay, notify-backoffcount, notify-interval, notify-ontimer, page-load, Pentecostal, Persistent-connections, plugin-expose-full-path, PluginDoc, plugins, Preferences, Process-Explorer, RAM, registry-settings, Rich-Tatum, sessionhistory, Sysinternals, trim-on-minimize, tweak, tweaks[/tags]