
Firefox has a well-established reputation as an aggressive memory eater due to persistent leak issues. With the new patch from Kyle Huey, this problem can be basically solved. But let's start from the beginning.
In Firefox, the memory allocated using JavaScript is divided into cells (compartments). Roughly speaking, all the memory used by JavaScript from one source (for example, from one site) is allocated in one cell. The memory used by JavaScript directly by Firefox also occupies one or several cells. Using this technique improves the security and localization of memory.
Starting with Firefox 13, you can see the used memory cells on the βabout: compartmentsβ page. Here, for example, what cells of memory are involved if the main page of a habr is opened.
')

When you close the page, all the cells associated with it should disappear. Well, maybe not right away, but when the cycle collector and the collector of links work. Sometimes, due to bugs in addons or Firefox itself, the cells are not deleted and remain in memory as zombie cells. This leads to an increase in the amount of memory consumed by the browser and increases the likelihood of the program falling. Sadly
But the brave and kind Kyle Huey, who wrote a
patch that eliminates the appearance of zombie cells for most situations, is already in a hurry to help the lisovodam (the patch is already available in the nightly builds of Firefox). The use of this patch reduces memory consumption several times (depending on how many plugin with leaks you used). This, finally, makes it possible to use the latest versions of Firefox on the not very powerful machines (such as devices with half a gigabyte of memory). But even if your life is good and you have 16GB of RAM, this patch will still accelerate the fox, as it will reduce the frequency of launching the garbage collector and the cyclic reference collector. And these two work in exclusive mode, forcing the entire program to freeze until they finish.
However, not everything is so rosy. Kyle's patch fixed a lot of leaks in add-ons, but opened a
leak in the Addon SDK. In version 1.6.1, this has already been fixed, but if your favorite addon was created using an earlier version of the SDK, then there is a reason to write a letter to the razrabetchiki to avoid
even more leakage like Wallflower, the addon for removing Facebook buttons and β+1β .
As you can see the hunt for the remaining zombie cells is in full swing and you can participate in it. For this:
- Open the fox (more or less modern version) page about: memory? Verbose.
- Open the test page with suspicious scripts and plugins and find how much memory it uses. For example, for the main page of the habr:
β ββββ3,579,160 B (05.06%) - compartment (http://habrahabr.ru/)
β β βββ,642,496 B (02.32%) - gc-heap
β β β βββββ514,680 B (00.73%) - shapes
β β β β ββ2323,560 B (00.34%) ββ tree
β β β β ββ230,880 B (00.33%) ββ dict
β β β β βββ444,240 B (00.06%) ββ base
β β β βββββ489,120 B (00.69%) - arena
β β β β βββ460,712 B (00.65%) ββ unused
β β β β ββββ15,576 B (00.02%) ββ padding
β β β β βββ128,832 B (00.02%) ββ headers
β β β βββββ369,104 B (00.52%) - objects
β β β β ββ210,656 B (00.30%) ββ function
β β β β ββ1515,448 B (00.22%) ββ non-function
β β β βββββ166,136 B (00.23%) ββ scripts
β β β ββββββ88,608 B (00.13%) ββ type-objects
β β β ββββββ14,848 B (00.02%) ββ strings
β β βββββ692,000 B (00.98%) - type-inference
β β β ββ3232,216 B (00.47%) ββ script-main
β β β ββ2295,520 B (00.42%) ββ object-main
β β β βββ6767,264 B (00.10%) ββ tables
β β βββββ456,328 B (00.64%) ββ script-data
β β ββββ3232,680 B (00.46%) - mjit
β β β ββ327,680 B (00.46%) ββ code
β β ββββ602,224 B (00.37%) - shapes-extra
β β β ββ104,992 B (00.15%) ββ tree-tables
β β β βββ9797,024 B (00.14%) ββ dict-tables
β β β βββ3131,328 B (00.04%) ββ tree-shape-kids
β β β ββββ26,880 B (00.04%) ββ compartment-tables
β β βββββ103,440 B (00.15%) - objects
β β β ββ100100,224 B (00.14%) ββ slots
β β β βββββ3,008 B (00.00%) ββ elements
β β β βββββββ208 B (00.00%) ββ misc
β β ββββββ90,016 B (00.13%) ββ analysis-temporary
β β βββββββ6,976 B (00.01%) ββ string-chars
- Close the suspicious page and click on the button βMinimize memory usageβ below (several times for reliability). This triggers the garbage collector and the circular reference collector and the corresponding cell should disappear. If this does not happen, then most likely she is a zombie.
- Check in 10-20 minutes - some zombies live for a while, and some - are immortal.
- Trying to figure out which script or addon causes zombies to appear.
- Post a bug in the
bugzilla , remembering to add β[MemShrink]β to the description and attach the output about: memory? Verbose.
Have a good zombie hunt and take care of your brains!