Many Firefox users notice that the open source browser can take a lot of memory, sometimes several hundreds of mega bytes. Fortunately Firefox lets you control to some extent how much memory it will consume.
To set the configurations you’ll need to edit Firefox settings. To do that you’ll need to type about:config in the address bar and edit the keys we’ll discuss in this article.
Cached Pages
When a page is loaded, it can be cached so it doesn’t need to be rerendered to be redisplayed. As a default Firefox will set the amount of cache memory according to the total amount of RAM your system got. The problem with that is that these values are per tab, so the more tabs you’ve got opened the more memory Firefox cache takes.
The config parameter is browser.cache.memory.capacity and you can set it to the number of KB you want let Firefox use for cache. Value of 0 will tell Firefox not to use any memory for cache. Note that the parameter browser.cache.memory.enable has to be true
The default value is -1 where Firefox will set the memory usage according to the following values
| Physical RAM
|
Memory Cache (in KB)
|
| 32 MB
|
2048
|
| 64 MB
|
4096
|
| 128 MB
|
8192
|
| 256 MB
|
14336
|
| 512 MB
|
22528
|
| 1 GB
|
32768
|
| 2 GB
|
45056
|
| 4 GB
|
59392
|
In Firefox 2 these defaults will change to the following:
| Physical RAM
|
Memory Cache (in KB)
|
| 32 MB
|
2048
|
| 64 MB
|
4096
|
| 128 MB
|
6144
|
| 256 MB
|
10240
|
| 512 MB
|
14336
|
| 1 GB
|
18432
|
| 2 GB
|
24576
|
| 4 GB
|
30720
|
To view current memory cache usage, type about:cache?device=memory in the address bar
Pages Stored In Memory
Pages that are visited are stored in memory in such a way that they don’t have to be re-parsed. Although it sounds like cache this is different from the cache. This setting improves performance of Firefox when pressing Back and Forward buttons.
The setting key to control this behavior is: browser.sessionhistory.max_total_viewers. The default value is -1 where Firefox use the following settings based on the amount of memory your system has.
| RAM
|
Pages
|
| 32MB
|
0
|
| 64MB
|
1
|
| 128MB
|
2
|
| 256MB
|
3
|
| 512MB
|
5
|
| 1GB
|
8
|
| 2GB
|
8
|
| 4GB
|
8
|
This preference limits the maximum number of pages stored in memory. Setting the value to 0 do not store any pages in memory.
Let Windows claim back memory
On Windows operating systems, when a program is minimized and left for a period of time, Windows will reclaim the memory the program used in anticipation that other programs might need it. Because of the way Mozilla applications are stored in memory, Windows is much more aggressive in reclaiming the memory they use, which can cause a delay when the program is restored. This preference determines whether to allow Windows to reclaim memory from a minimized Mozilla application.
Firefox’s default setting prevents Windows from reclaiming memory when the program is minimized.
To change this settings you’ll need to change or create the key config.trim_on_minimize and set it to true or false. True - allows Windows to reclaim back the memory and false (default) prevents Windows from doing that.
Note: Changing Firefox’s settings may not be enough to stop it from taking too much memory, plugins can also be a big factor in memory consumption.