Reading the Numbers
memlab and the Chrome DevTools heap profiler read the same snapshot, but a few figures are defined or grouped differently. memlab's reports also classify growth and fold long results in ways worth knowing before you read them.
Compared with Chrome DevTools
| memlab | Chrome DevTools |
|---|---|
| Self size | Shallow size |
| Retained size of an object | Same definition (from the dominator tree) |
Class retained size (memlab_class_histogram with include_retained_size) counts each byte once, even when instances hold one another | Same as the profiler's constructor rows. In both, rows overlap across classes, so they don't add up down the table |
Class keys are type::name, such as closure::onClick or object::Map | Grouped by constructor name, with (closure), (string), (array) and (system) groups |
Total is the root's retained size plus extra_native_bytes | Same |
Distance and detachedness (memlab_get_node) | Same: hops from the root, with page globals at 1; attached, detached or unknown |
By default, memlab's lists leave out engine-internal node types (arrays,
code, native and synthetic nodes). Ask for them by node_type.
How Growth Is Classified
Every ladder table (memlab_eval_across with compare: "growth",
memlab_collection_diff, memlab_collection_trend,
memlab_sequence_analysis, memlab_leak_report, and the growth section of
memlab_sweep) prints one Shape per row, computed the same way, beside
the last-interval Δ:
| Shape | Meaning |
|---|---|
linear | Every interval grows, at a similar rate per cycle or a rising one |
step→flat | All the growth is in the first interval, then nothing |
late-step | The growth is in one later interval, or arrives at the settle rung |
drains-at-settle | The settle rung gives back at least 90% of the growth |
transient | Rose and fell back within the ladder, or shrank |
flat | No change |
unknown | Two readings, or growth that fits none of the above |
Only linear with a non-zero last-interval Δ that survives the settle rung is
a leak candidate. A step that stays flat for the rest of the ladder also
"grew at every step" (it never fell), which is why that test is no longer
printed. A ladder without a settle rung prints linear (no settle): the rate
is there, but whether it survives idle is unknown. memlab_census_diff
compares two rungs only, so its rows have no shape.
memlab_leak_report doesn't count every growing class as a leak:
Not
linear: a class that grew at every step but whose Shape is another one (a step then flat, a late step, or two rungs) reads↑ every step but <shape> — not a leak candidate.SATURATING: a class that grows at every rung, but by less each time (preloading, things loaded on first open). Once its last step adds under 20% of what its first step did, it is not a leak candidate.ONE-TIME: a class with at least 80% of its growth in one step, and less thanmin_growth_countover the other steps. Not a leak candidate either.STEP+LINEAR: a jump (such as a first mount) followed by steady growth. The rate after the jump is the leak rate; the overall change per cycle overstates it.Rows that grow together are one leak. Rows whose change is the same, or a whole multiple of it, at every step are grouped. A leaked subtree, for example, shows up as a detached element, the listener holding it and the scope holding the listener, each growing once per cycle. The group says to trace one of them.
Other tools apply similar rules:
memlab_settle_checksays "grew further at rest" only when a class gained more than 10% of its growth (and more than two instances) between the last busy rung and the settle rung. A survivor that is a capped browser buffer still under its cap (Blink's console message storage keeps 1,000 messages, the Resource Timing buffer 250 entries) is reported asbounded, with its fill and the cycle at which it reaches the cap, not as a leak candidate.- A whole-number rate points to a cause.
memlab_compare_roundslists every population whose rate is a whole number per cycle, or per step the round drove, with the step it matches. For example, an interaction that opens two chats per cycle shows 2.000 per cycle for one record per opened chat, and the table says1 per open-chat. - Growth per unit of content counts app memory only. When the round
records how much content the account holds (chats, messages, rows),
memlab_leak_reportlists growing classes whose growth is a whole number per unit of it. A class held at least 80% through development or automation roots, or reached through a devtools module, is left out, and so is one with more instances held only through those roots than 2% of its growth (the ratio's tolerance), and the report counts both. On a development build, Fast Refresh bookkeeping otherwise grows by exactly one per rendered item. - Bounded windows are reported apart. A collection that the app empties
on a timer (a 30-minute trace buffer, a cache with an expiry) fills for as
long as its window lasts, so on a short ladder it looks like steady app
growth.
memlab_artifact_budget({windows: [{name, edge, value_keys}]})measures what releasing each window's entries would free, and givesapp_deltawithout them.
Development Builds
A development build holds memory that production doesn't, so some figures leave it out:
- Production-only totals.
memlab_explain_deltaandmemlab_ab_comparereport growth without memory held only through development roots and references: React Fast Refresh registries, React_debug*fields, DevTools globals, and the React Compiler's development hook guards. The raw figure is shown beside it. On a development build, one hash table that only exists there can double in size partway through a run, and the raw total then grows by megabytes with no change in the app. - Dev-only means unreachable without the dev edges. A node is dev-only
when no path from a GC root or a module's top-level scope survives once
every dev edge is cut. The shortest path is not the test: on a development
build it often runs through Fast Refresh, which closes over every module
that defines hooks. A node whose shortest path crosses a dev edge but that
still has a production path is labelled
production-reachable (dev path is only the shortest), and both paths are printed. Inmemlab_detached_dom, aDev-onlycell like398/795means the row also holds production members: it is a production population with some dev-held copies, and the evidence lines under the table show a path for each kind. - Devtools modules and the measurement harness. A module whose name marks
it as devtools plumbing (
BrowserTools*,*DevToolsInterop, or your ownMEMLAB_DEV_MODULE_PATTERNregex) is found by its module-registry record, so it is subtracted on a minified build too, where module factories have no names. Functions a measurement harness installs in the page (marked with an own__memlabHarnessproperty, or pass-through closures over exactly{self, key, orig}) and__memlab*globals count as Dev/automation-retained inmemlab_artifact_budget,memlab_explain_deltaand the other production-only totals. The function a wrapper passes through to stays app memory, and path labels skip the wrapper (global:clearInterval, notglobal:clearInterval.orig); anything else under it is labelledharness:<name>.harness_as_app: true(orMEMLAB_HARNESS_AS_APP=1) counts the harness as app memory again. - Named patterns.
memlab_dev_artifactstags the known development-build patterns it finds (react-compiler-hook-guard,owner-stack-event-path,devtools-consoleandfast-refresh-registry), each with its size and the tool that shows it in detail.
Minified Builds
- Minification renames variables, not record fields. A probe that looks a
collection up by its variable name finds nothing on a production bundle. A
probe stuck at its own "not found" value at every rung is reported
UNRESOLVED, not FLAT or FAIL. A
map-sizepositive control can declarevalue_keys, the property names its values have, so it is still found by shape after the variable is renamed. - Module names survive.
memlab_sparse_elements,memlab_cache_analysis,memlab_stale_collectionsandmemlab_growth_signalshave aModulecolumn: the module whose code holds each row's object. On a production build, this is often the only readable label. - Minified component names. A production bundle names components
Corr.memlab_react_update_queuesadds the module that defines the component (for exampleC [ChatListItem.react]). - Code with no module is named by its script. Where no module owns a
closure,
memlab_scope_chainslabels the chain(no module) app.min.js:1:4812(the position of its most common linking closure; across rungs the chain is matched as(no module) app.min.js via Q, Q being the linking variable),memlab_retainer_traceadds "Nearest closure on the path: … code in app.min.js:1:4812", andhelpers.pathLabelreturnsscript:app.min.js:1:4812instead ofroot. The file is the script's basename with its query trimmed; the line and column (1-based) appear only when V8 recorded a position for the closure, which it does for few functions. The server does not load source maps, so the names stay minified.
How Results Are Shown
Shorter Reports
- Engine code is summed, not ranked.
memlab_explain_deltaandmemlab_dev_subtracted_deltaput V8's own code (compiled code, bytecode, feedback and inline caches) on one line. It grows as new code paths are compiled and shrinks when unused code is flushed, so it would otherwise fill the top of the table with rows no app fix can change. Passinclude_engine: trueto list it. - Explanations are printed once per session. A tool prints the note that
explains its figures the first time in a session, and after that only says
how many notes it left out.
repeat_notes: trueprints them again.memlab_load_snapshotprints the notes about the app (duplicated strings, high instance counts) on the first load of that app's snapshots, says once that it left them out, and then stays quiet; the advice about replacing a loaded snapshot is printed once per session.verbose: trueprints all of them on one load. - Long retainer paths are folded.
memlab_retainer_traceprints a repeating pattern (such as a scope chain alternating closures and Contexts) once, with its repeat count, and keeps only the first and last 20 steps of a path that is still longer.expand: trueprints every step.
Detached DOM
- Compared by owner, not by id. With a
baseline,memlab_detached_dom({group_by})shows each group's count in the earlier snapshot and sorts by the change, so a large group that was already there reads as a standing population, not a new leak. Ids can change between captures, so owners are matched by class, and a scope by the names of the closures over it. - One row per kind of owner.
memlab_detached_dom({group_by: "dominator"})puts owners of the same class and module in one row, marked×N, instead of one row per object. It also gives the shortest retainer path of the top row's largest owner. When that row has 1,000 detached nodes or more, it lists every reference from the app into them (memlab_island_doors), because a fix that closes only the shortest path frees nothing while another holder remains.island_doors: falseskips that step.
Other Groupings
- Rare path shapes. After its
limitof clusters,memlab_trace_alllists up to 15 more path shapes, one line each. New kinds of leaks often first appear as one of these small clusters. - How the newest instances are held.
memlab_trace_allwithsample_target: 200, sample_order: "newest"traces the 200 instances allocated last (the highest heap-object ids) and clusters their retainer paths, each cluster with its count, share and an example id. The defaultsample_order: "spread"samples across the whole population, so comparing the two shows whether the growth is held differently from the rest. The path of one or two listed ids is not evidence about their class, andmemlab_retainer_summarysays so instead of reporting a single root cause. - Duplicated fields can be one duplicated object.
memlab_duplicated_stringsalso groups the largest duplicated values by the object shape that holds them. Three values duplicated about 1,400 times each, held as three fields of one shape, are reported as at least 1,400 copies of that object: the object is what to deduplicate. setStatecalls that change nothing. Over a ladder,memlab_react_update_queuesnames the setter behind each component's longest queue of pending updates (for examplesetIsActive(false)), and says whether every pending update sets the value already rendered. Components whose updates grow from such calls are listed separately: each is a call site to guard. Calling it again on the same rungs (asmemlab_analysis_batterydoes) returns the earlier report instead of scanning again. For one snapshot, passsnapshot(a handle or a path) to read it without loading it first.- Source for a node.
memlab_source_for_nodeprints the function behind a closure from its module's span in the served bundle. On a minified line, it prints a window of characters instead of lines. For a Context, it also lists the variables and the closures over it, which is usually enough to tell which component's render scope it is.
Write-Ups
memlab_round_digest({run_dir, format: "doc_markdown", compare_to}) prints a
short Markdown section for a team document: the run, the audit verdict, the
heap after garbage collection, detached DOM nodes, leak candidates, a
comparison with the previous round, a Next line with the specialist calls
for the leak candidates, and a TODO line for your reading.
The second memlab_round_digest or memlab_leak_report for the same run in
a session prints a compact form and says so: the verdict, the blocking checks,
the growth rows and the next steps, without the caveats and explanations you
have already read. Pass compact: false for the full report.
Both reports end with Applicable tools not run this session: up to three
calls, with their arguments filled in, that apply to this round and whose tool
this server has not run yet. They are the specialist tools for the growing
classes, memlab_growth_atlas when the round has no atlas, and
memlab_leak_report when the digested round has no leak report. Once you run
one, later reports stop naming it.
Work Without Retention
Some problems leave the heap flat: a request loop, a retry storm, an error
screen that never goes away. A leak report cannot see them. When a round
samples the page between rungs (samples.jsonl), memlab_activity_report({run_dir})
credits each sample's counters to the combo that was driving. It reports per
combo the requests per minute, resource errors, unhandled rejections,
long-task time and time on an error screen. Rows are ranked against the idle
control round (baseline_run_dir, or a sibling directory named *idle*), or
against the round as a whole when there is none. An idle control that took no
samples is read from its run.json per-rung request windows instead, which
give resources per minute and nothing else; the report says so. Below the
table it lists the
most-requested paths with their HTTP statuses, from the per-rung request
windows in run.json. A combo making ten times the requests of the control is
flagged.
When the samples also carry a work dict (cumulative counts of calls the page
made, by name: storage reads per store, listeners added per event type,
timers created) and a cycles count, a Work counters table ranks each
combo's counters per cycle and per minute against the idle control, or
against the round as a whole when the control recorded none. Paired counters
left apart every cycle are flagged: x.add… over x.remove…, .set over
.clear, .observe over .disconnect. A combo that reads storage thousands
of times per cycle with a flat heap shows here and nowhere else.
Counters Between Rungs
Rungs are sparse: a snapshot of a large heap takes tens of seconds to capture
and parse, so a round has five or six. A runner can also count a few objects
over the DevTools protocol on some of its samples, with no snapshot: live
Promise objects (Runtime.queryObjects(Promise.prototype)), detached DOM
trees and the nodes they hold (DOM.getDetachedDomNodes, an experimental
method, used only where the browser has it), and the heap right after the GC
those reads force. Each such sample carries promises, detached_trees,
detached_nodes, heap_gc_mb and counters_ms; heap_gc_mb only when a
count actually ran on that sample, since only a count forces the GC.
memlab_leak_report({run_dir}) (in "Between rungs") and memlab_round_digest
fit each counter over the driven cycles and call its shape: FLAT, LINEAR,
STEP or RISING (noisy), then HELD or DRAINED at settle when the round has a
settle idle. A STEP is judged per cycle: one gap between reads holding most of
the rise is a STEP only when its rate per cycle is well above the rest's, so
reads spaced unevenly over a steady rise are LINEAR. Counts reset on a reload, so only the last document's reads are
fitted. Each read forces a full GC, so a runner should space the reads (tens
of seconds apart) and must not take one while it captures a rung: the
queryObjects result array holds every promise until it is released.
Rounds From Another Machine
A round's directory stays on the machine that ran it. When the home directory
is shared between machines, the round index makes finished rounds readable
from all of them: ~/.memlab-mcp/rounds/<app>/<round>/ (or the directory in
MEMLAB_ROUND_INDEX) holds each round's summary.json and copies of its small
files (run.json, samples, analysis output), but no snapshots. A runner
publishes a round there when it ends, and memlab_analysis_battery refreshes
the copy of an indexed round's analysis. Pass the round's name where a run
directory is expected: memlab_round_digest({round: "r425"}), its
compare_to, and memlab_compare_rounds({run_dirs: ["r424", "r425"]}). Add
the app ("whatsapp-web/r425") when two apps share the name. A digest read
from the index says so and names the machine and directory the round ran in.