I came to the conclusion Firebug is a big part of the problem due to the orphaned compartments, and laid some scorn on the people at the top of Mozilla for not allocating sufficient resources so it gets fixed. Just to be clear, Firebug does seem to be funded by Mozilla, and is essentially Firefox's equivalent of what the other browsers now have built in. Don't get me wrong, I love Firebug, and the concepts it pioneered has changed the lives of web developers, and I think Firefox was a real pioneer too – but I really think for an organisation with so many resources, and such a legacy of great engineering, something is seriously wrong with the management.
Anyway, after disabling Firebug I'd hoped I'd see the probems resolved. Unfortunately not, because my memory has been creeping up today too.
There's nothing wrong or unusual with my machine or Firefox install. The Firefox install is basically fresh, as I have only been using it for testing since installing my OS a few months ago. I'm on a very standard iMac.
So I thought I'd run some more tests today. I created a simple technique to monitor how Firefox is using memory:
- Open Firefox (it has to be set to not load a home page – it has to start blank)
- Go to "about: memory"
- Wait a few seconds until things settle (very important)
- In the Mac "Activity Monitor" tool, record what the "Real mem" value is
- Open a specific folder of 14 bookmarks in new tabs (using "Open all in tabs" from the bookmarks menu)
- Wait for them to load
- Close them all
- In the "about memory" tab we initially opened, click "Minimize memory usage". There should not no identifiable URLs showing as compartments. If there are, wait a few seconds, and try again. This is important to make sure any background downloads are finished, because Firefox won't free the RAM until they have.
- Record the "Real mem" value, after things have settled on there (again, very important – the OS has to be given enough time to finish and outstanding processes and to free up deallocated RAM)
- Go back to step 5, repeating 2 more times (ideally we'd do more tests, but I haven't got much time)
I did this process for different combinations of installed addons, with the following results:
No addons at all
ColorZilla, Console2, Copy Urls Expert, LastPass, Live HTTP Headers
ColorZilla, Console2, Copy Urls Expert, LastPass, Live HTTP Headers, MeasureIt, RAMBack
ColorZilla, Console2, Copy Urls Expert, LastPass, Live HTTP Headers, MeasureIt, Page Speed, RAMBack
ColorZilla, Console2, Copy Urls Expert, LastPass, Live HTTP Headers, MeasureIt, Page Speed, RAMBack, Selection Links, Web Developer, Xmarks
(continued on further on this one to show the pattern continues)
As you can see, the first step 9 measurement has a big increment over the initial step 4 measurement. That is to be expected because Firefox will be loading up various libraries upon demand (or similar), to serve the functionality required. It is correct that Firefox doesn't free these later on, because they'll be needed again. It makes sense from a programming and performance point of view to load framework stuff on demand but to keep it.
The next measurement shows roughly 7MB, then roughly it takes 3MB for each repeat trial, all regardless of what addons you have. This makes sense because Firefox is configured with a 5MB cache so I'd expect initially things would fill up a bit but for that trend to not continue. The key thing is the 3MB, which translates to 219KB per page of leakage (1024*3/14). The data is a bit noisy, but that's to be expected, you can still see something is going on here.
If this was a proper scientific process, I'd repeat it for other browsers, take more data points, and I would look into detail on how the exact figures in "about: memory" change. But I think this is enough to show there is a real problem here. The 219KB leakage happened for pages that were initially opened and closed very quickly. Whatever the leaks are, interacting with pages likely causes it too, so real leakage will be higher - and these multiply up quickly.