(if you don’t have technical background, it might be better to skip this – I’m sorry to have to stress this)

First things first, after using the strategy (am I really using this word? Isn’t workaround much more accurate) Gustavo mentioned, I managed to reduce my Firefox footprint to only (am I really using this word?) 150 Mb. I’m currently using 2 windows and a total of 6 tabs. Two major things have happened after I changed the browser.sessionhistory.max_total_viewers parameter:

1 – Both “Mem Usage” and “VM Size” went drastically down (to about a half).
2 – “VM Size” approached “Mem Usage” while previously it was much bigger.

1 allows us to reach the La Palisse conclusion that if you disable Firefox’s Back-Forward caching you save memory. It also suggests that this Back-Forward cache works in a very weird way that makes it use much more memory than you would expect.
2 suggests that Firefox does leak a lot of memory if you leave it on for days (which I do regularly). Why? To answer this we need really to look deep into the subject.

This is what I think of it all:

Firefox uses something they call a Back-Forward cache. This means that a number of pages you have seen are kept at hand when you “leave” them in order to speed up successive accesses made particularly by using the “Back” and “Forward” browser buttons (by the way, what does it mean to you to “leave” a webpage? Closing it? Stop looking at it? Remember that an HTTP request is episodic -> you send it, the server sends you the document, end of story. The rest is up to the browser.).

It is important to notice that this cache is not per-tab (see the final Edit in this post).

According to the same source, the Firefox configuration parameter browser.sessionhistory.max_total_viewers is defaulted to “-1″, which instructs it to use a sensible table associating Total RAM Size with the Number Of Pages cached by this feature. This table is so sensible that if you happen to have only 32Mb of RAM, it causes 0 pages to be cached. Sensible indeed. This number grows as your RAM grows, quite sensibly, until you get to those lucky guys who have 1Gb and more of RAM. Those guys get to have 8 pages cached. For 1Gb+, Mozilla apparently thought that 8 was good enough and nobody would be interested in caching more than 8 pages anyway…

In my case, I have 512Mb of RAM, I get 5 cached pages. If you recall, this is not per-tab, which means that I can have 100 tabs and I only get 5 cached pages (this is perfectly fine, any other way would probably yield catastrophe). This also means that in theory I can leave Firefox on for a month, use it intensively, and I will never have more than 5 cached pages. Fine. And 5 pages is usually absolutely nothing in terms of occupied memory. At this point, I would like to say that claiming that this “feature” has anything to do with a big footprint largely puzzles me. If it works as it’s explained in the above source, I don’t understand how one thing influences the other to such a huge extent.

But I’m getting away from my goal. Why is it then that the fact that “VM Size” approaches “Mem Usage” if you disable this Back-Forward cache suggests that Firefox does leak a lot of memory if you leave it on for days.

What are “VM Size” and “Mem Usage”? In this context, they are designations created by Microsoft in its “Windows Task Manager”. A bit loosely, but trusting the Task Manager help, it seems that “Mem Usage” represents the amount of RAM currently occupied by the process. As you should know from Operating Systems 101, Computer Architecture 101 and such other wonderful subjects, this is NOT the actual size of the process – how big it is – because some of it will usually be resting on your hard drive because your OS noticed that you hadn’t used some parts of it for a while. Your process is split, some parts in central memory, others in secondary memory. “VM Size”, meaning Virtual Memory Size, I trust, gives us the actual size of the process, how big it is. And the problem, recall, is that my Firefox instance is currently occupying more than 160 Mb of my RAM, i.e., has a “VM Size” of 160 Mb.

One of the consequences of this is that if you don’t use a program for a while but still keep it running, “Mem Usage” will go down while “VM Size” will usually stay more or less where it was. How much “Mem Usage” goes down depends on what is considered “necessary” to be in memory for a given process at a given time.

The fact that “Mem Usage” and “VM Size” are similar can mean one of two things:

- that the process is currently being used
- that the OS isn’t being able to identify pieces of the program that are suitable to be written out of memory and to disk

(to be continued…)

Deixe uma resposta

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">