I recently wrote about bug 654106, a memory leak that has been fixed. In bug 653817 the reporter made some measurements that show this leak was quite a bad one. The reporter measured “Uss” using procrank on an Android device. This page says:
“Uss is the set of pages that are unique to a process. This is the amount of memory that would be freed if the application was terminated right now.”
Comment 19 and comment 24 have the numbers before and after the leak was fixed. The reporter opened Firefox (with a single tab containing about:memory), measured the memory usage, then opened 8 popular sites, re-measured several times, then closed them all (except about:memory), re-measured, then re-opened them, and so on through several cycles. The following table shows the key measurements from the first cycle.
|Start-up||47,972 KiB||48,700 KiB|
|Open 8 tabs, wait 90 minutes||251,844 KiB||240,064 KiB|
|Close 8 tabs||226,328 KiB||108,908 KiB|
These measurements have some noise, so don’t read too much into the minor differences. The important difference is the last row; the Uss after closing the 8 content tabs was 2.1x smaller after fixing the leak!
So, this is a great leak to have fixed. But I have several concerns remaining.
- It’s worrying that such a bad leak was able to get into Firefox 4.0 and remain undetected for this long. My understanding is that we have various kinds of automatic leak detection tools, but I don’t know much about them, why they might not have detected this, and whether they could be improved.
- The Uss after closing the 8 tabs is 2.2x higher than at start-up. That seems high. One thing I’ve been trying to understand lately is what kind of memory usage can legitimately remain when a lot of tabs have been closed and there’s only one left. Obviously there’s a bunch of chrome stuff, but when I look at detailed profiles it’s hard for me to tell what things fall into that category and what doesn’t. (One thought I had was that it might be worth doing some profiling on Mac, because it’s possible on Mac to close all browser windows without closing the browser itself. Would all this chrome memory still remain in use in this case?)
- Each time the bug reporter re-did the open/close cycle, the Uss after closing the tabs crept higher. In the post-fix run, it was 108,909KiB the first time through, but the next three times through the figure was 121,552 KiB, 123,692 KiB, 127,588 KiB. That smells like another leak (or more than one).
I read a lot of browser-related threads on tech websites. They almost always descend into slanging matches where people explain why browser A is awesome and browser B sucks. My perception from these threads is that memory leaks (be they real or perceived) are one of the things people complain about most with Firefox. This is usually based on a measurement similar to the one described above — the person browses for a while, closes all their tabs except one, and memory usage is still high. I’d love to hear any ideas people have about how to improve things on this front.