Confirmed users
1,345
edits
Nnethercote (talk | contribs) |
Nnethercote (talk | contribs) |
||
Line 3: | Line 3: | ||
Mozilla code has infrastructure that lets different parts of the code report on their memory usage. This is most obviously used in about:memory and telemetry. This document describes things that you should know when writing a memory reporter. | Mozilla code has infrastructure that lets different parts of the code report on their memory usage. This is most obviously used in about:memory and telemetry. This document describes things that you should know when writing a memory reporter. | ||
== | == Memory Reporters == | ||
A memory reporter makes one or more memory measurements (a.k.a. reports). A reporter that only makes a single measurement is called a uni-reporter; one that makes multiple measurements is called a multi-reporter. | |||
Each reporter implements a <tt>collectReports</tt> function which takes a <tt>nsIMemoryReporterCallback</tt> argument; for each measurement the reporter must pass in several values, including: | |||
* a path (which identifies the | * a path (which identifies the report); | ||
* an amount (the most important thing); | * an amount (the most important thing); | ||
* a unit (most commonly bytes, but sometimes a unitless count or percentage); | * a unit (most commonly bytes, but sometimes a unitless count or percentage); | ||
* a description of what is measured. | * a description of what is measured. | ||
See the [https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIMemoryReporter nsIMemoryReporter documentation] and [http://mxr.mozilla.org/mozilla-central/source/xpcom/base/nsIMemoryReporter.idl nsIMemoryReporter.idl] for full details | See the [https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIMemoryReporter nsIMemoryReporter documentation] and [http://mxr.mozilla.org/mozilla-central/source/xpcom/base/nsIMemoryReporter.idl nsIMemoryReporter.idl] for full details. | ||
The <tt>MemoryUniReporter</tt> class makes memory uni-reporters easy to write. | |||
== Making Measurements == | == Making Measurements == |