Performance/MemShrink/about:memory

From MozillaWiki
Jump to navigation Jump to search

about:memory is a special page that lets you view, save, load, and diff detailed measurements of Firefox's memory usage. It also lets you do other memory-related operations like trigger GC and CC, dump GC & CC logs, and dump DMD reports.

Type "about:memory" into the browser's address bar to view it.

Things that make your life easier

Almost everything you see in about:memory has an explanatory tool-tip. Hover over any button to see a description of what it does. Hover over any measurement to see a description of what it means.

You can copy and paste part or all of about:memory's contents into any text buffer. This is much easier than taking screenshots.

Memory reports are saved to file as gzipped JSON, and by default are given a .json.gz extension. These files can be loaded as is, but they can also be loaded after unzipping.

Memory reports can be loaded automatically when about:memory is loaded by appending a file query string, for example:

about:memory?file=/home/username/reports.json.gz

This is most useful when loading memory reports files obtained from a Firefox OS device.

Measurements

Basics

Most measurements use bytes as their unit, but some are counts or percentages.

Most measurements are presented within trees. For example:

 585 (100.0%) -- preference-service
 └──585 (100.0%) -- referent
    ├──493 (84.27%) ── strong
    └───92 (15.73%) -- weak
        ├──92 (15.73%) ── alive
        └───0 (00.00%) ── dead

Leaf nodes represent actual measurements; the value of each internal node is the sum of all its children.

The use of trees allows measurements to be broken down into further categories, sub-categories, sub-sub-categories, etc., to arbitrary depth, as needed. All the measurements within a single tree are non-overlapping.

Tree paths can be written using '/' as a separator. For example, "preference/referent/weak/dead" represents the path to the final leaf node in the example tree above.

Sub-trees can be collapsed or expanded by clicking on them. If you find any particular tree overwhelming, it can be helpful to collapse all the sub-trees immediately below the root, and then gradually expand the sub-trees of interest.

Sections

Memory reports are displayed on a per-process basis, with one process per section. Within each process's measurements, there are the following two subsections.

  • "Explicit Allocations". This tree measures all the memory allocated via explicit calls to heap allocation functions (such as malloc and new) and to non-heap allocations functions (such as mmap and VirtualAlloc).
  • "Other Measurements". This collection of trees includes many that cross-cut the measurements in the "Explicit Allocations" tree. For example, in "Explicit Allocations" all DOM and layout measurements are segmented by window, but in "Other Measurements" those measurements are aggregated into totals for the whole browser.

On Firefox OS, there is also a "System" section which contains whole-device measurements obtained from the operating system. Among other things, this section is useful for understanding exactly how the whole device's memory is being used.

Notable measurements

The exact set of measurements shown in about:memory changes frequently. However, here are some notable ones.

  • "explicit". This value is at the root of the tree in the "Explicit Allocations" section. As mentioned above, this represents all the memory allocated via explicit calls to allocation functions.
  • "resident". Physical memory usage. If you want a single measurement to summarize memory usage, this is probably the best one.
  • "vsize". Virtual memory usage.
  • "heap-unclassified". This is heap-allocated memory that is not measured by any memory reporter. This is typically 10--15% of "explicit". If it gets higher, it indicates that additional memory reporters should be added. Performance/MemShrink/DMD can be used to determine where these memory reporters should be added.