A while ago I wrote about some ideas I had for improving about:memory. Bug 653633 has been tracking the first stage of this (and it now also has a feature page) and it only needs to pass super-review to be ready for landing.
Here’s what the old about:memory looks like.
Some things to note:
- The “Memory mapped” and “Memory in use” numbers are for the heap, not the entire process.
- The “Memory mapped” and “malloc/mapped” numbers are the same, as are the “Memory in use” and “malloc/allocated” numbers (modulo tiny differences due to memory allocations that occur while generating the page).
- It’s a big list without much information how the different entries relate. If you hover over the names you get a tool-tip that explains a bit more, but it’s often not much of a help.
- Something not obvious from the above screenshot is that if you cut and paste the output into a text box it looks horrible. Eg. see this Bugzilla comment. This makes it hard to use in Bugzilla reports.
Here’s what the new about:memory looks like:
Things to note:
- Most of the output use a tree-based representation which shows the hierarchy of the memory breakdown. I.e. overall use is broken into multiple chunks, and each of those chunks are broken into sub-chunks, and so on. This makes it much easier to see where the bulk of the memory usage is occurring.
- The use of percentages helps with this too.
- Sizes are reported in MB, not bytes. (I wanted to use “MiB” instead of “MB”, but was discouraged by the prior holy war about this issue that bug 106618 documents!)
- The “Mapped Memory” tree gives the high-level overview. The root of that tree is the total memory used by the process (which the old about:memory did not list).
- The “Used Heap Memory” tree gives the breakdown for the used part of the heap (which corresponds to the “mapped/heap/used” figure in the “Mapped Memory” tree). I show the used heap separately because most of the time that’s the most interesting information. In contrast, the “Mapped Memory” tree is often dominated by code and data segments, which don’t correspond to explicit memory allocation requests from the process and so are less variable and harder to improve.
- “Other Measurements” holds measurements that overlap with the tree breakdown. The new “resident” figure tells you how much physical memory is being used by the process.
- Entries that cover a very small section of memory (less than 0.1% of the used heap, for the “Used Heap Memory” tree) are aggregated into entries that look like “(2 omitted)”. This means that more memory reporters can be added in the future without the output being cluttered up by tiny entries.
- If you click on the “More verbose” link at the bottom, the page redraws showing all the sizes as bytes instead of MB, and aggregated entries are shown in full.
- It handles multiple processes. If you view about:memory in Fennec you get output for each process separately. The plug-in container process isn’t represented at the moment, though; bug 648415 is open for adding that, though it’s of less interest since plug-ins like Flash are out of Mozilla’s control.
- You can’t see it in the picture, but the tool-tips describing each metric are clearer, more consistently expressed, and expressed as complete sentences.
- The formatting is much more similar to other “about:” pages such as about:cache and about:buildconfig.
- You can cut and paste the output into a text box and it reproduces beautifully. The lines used to represent the tree structure are Unicode box-drawing characters, and I stuck to the subset that are most commonly supported by terminals. The generated HTML has newlines in just the right places so that whitespace is inserted nicely. Here’s an example:
Main Process Mapped Memory 634.89 MB (100.0%) -- mapped ├──526.33 MB (82.90%) -- other ├──106.00 MB (16.70%) -- heap │ ├───53.34 MB (08.40%) -- used │ └───52.66 MB (08.29%) -- unused └────2.56 MB (00.40%) -- js ├──2.44 MB (00.38%) -- mjit-code └──0.13 MB (00.02%) -- tjit-code Used Heap Memory 53.34 MB (100.0%) -- heap-used ├──22.22 MB (41.65%) -- js │ ├──21.00 MB (39.37%) -- gc-heap │ ├───0.75 MB (01.41%) -- tjit-data │ │ └──0.75 MB (01.41%) -- allocators │ │ ├──0.56 MB (01.06%) -- reserve │ │ └──0.19 MB (00.35%) -- main │ ├───0.35 MB (00.66%) -- mjit-data │ └───0.11 MB (00.21%) -- string-data
The screenshots above are from my Ubuntu Linux box. Funnily enough, on Mac the lines in the box-drawing characters don’t line up consistently so the output doesn’t look as nice, as this screenshot shows:
Not much that can be done about that, as far as I know; it’s certainly not a show-stopper.
My hope is that this revamped about:memory will be the first place both users and developers look when trying to understand any issue related to memory usage. For example, it should subsume OS memory reporters like ‘top’, ‘ps’ and the Windows task manager. This will make bug reports easier to understand; in particular it will help avoid the problem where someone says “Firefox is using 800MB of memory” and you don’t know which metric they are using.
There are some definite improvements to be made. Most notably, the “heap-used/other” entry is usually the largest one in the “Heap Memory Used” tree — large chunks of memory aren’t being covered by memory reporters, so new ones need to be added. Working out what these reporters are won’t be easy, but Massif should be a big help.
After that, it’d be great to have reporting at the level of individual tabs or something like that. Mike Shaver has a draft patch adding an about:compartments page which reports about JavaScript memory usage for individual compartments, which correspond to domains. This is a great start, though I’d like non-JavaScript memory usage to also be divided in this way. The details of how best to do this are not yet clear to me.
The new about:memory is on track to make it into Firefox 6. Hopefully it will help reduce Firefox’s memory consumption.