Skip to main content

Who owns the growth / why is X retained?

These tools are in the retention toolset. Starting the server with MEMLAB_TOOLSETS=retention exposes only them, plus the few tools every session needs, and memlab_tools({enable: "retention"}) turns them on in a session. Try them in the order listed.

ToolUse it when
memlab_cohort_ownersPer growing class, who owns its NEWEST instances (the cohort a ladder added): each mapped to its owner and tallied by the owner's shortest-path label (module:<Name>.<export>, global:<name>), with the owners' retained size and whether the owner is the measurement harness or a dev-only module. The leak report's "Top retainer" column is its top row over 200 instances.
memlab_react_ownersName the React COMPONENT behind a population of plain Objects. Fibers and hooks are all Object in a production bundle, so every class-name heuristic — including helpers.owner — walks past them. With no population argument it attributes the React update records (update_records: true).
memlab_react_stale_refsLive React state pointing at dead UI: effect cleanups on MOUNTED fibers that captured now-detached DOM (grouped by component and variable, with hook scope and module), and Map/Set/object registries holding scope instances, DOM nodes or fibers of UNMOUNTED components, with bytes freed by deleting them.
memlab_stale_context_snapshotsReact context consumers still holding an OLD context value: dependencies.firstContext*.memoizedValue differs from what the nearest provider supplies now (or the context default), so the old value and what it closes over stay alive through that record. Grouped by context and consumer component, with the bytes only the stale snapshot retains and whether the consumer is mounted.
memlab_population_vs_ownersSTRUCTURAL or ACCUMULATING? One record per live owner is a baseline; many records per owner is a leak.
memlab_chain_walkWalk a repeated linked structure (.next update queues, .prev closure chains, LRU lists) and report how deep it goes — use this instead of a hand-written loop, which cannot tell a cycle from a hop cap.
memlab_module_attributionAttribute bytes to the MODULE that owns them, by walking dominators up to the nearest module-registry export.
memlab_censusCount several named populations (detached DOM, listener records, LRU cache nodes, React fibers, timers, …) across every rung in ONE pass each, with per-cycle rates and a settle verdict.
memlab_ab_compareJudge an A/B round in one call: the same probes on the OFF and ON arms, per-cycle rates, ON/OFF ratio and a FIX EFFECTIVE / NO EFFECT / CANNOT JUDGE verdict per metric, plus each arm's heap total with dev-only memory removed. Each arm's first interval is left out of the fit when the round shows the page load still settling (a post-GC step, a new isolate), and the header says what was left out.
memlab_object_urlsUnrevoked blob: object URLs per rung — their Blobs are pinned OFF the V8 heap, so this leak never shows in heap size.
memlab_cache_sole_retainerModule-level caches counted by the objects that ONLY caches keep alive (reachability with every cache refused): objects the app let go; per-cycle growth across a ladder.
memlab_bound_functionsBound functions (native_bind) grouped by target function and module, receiver or first bound argument (a React setter names its component), and holder; per-cycle growth across a ladder.
memlab_rate_tableRank several rounds by the per-cycle rate of ONE population, labelled by the surface each round drove — the "which surface do I fix first" table. Carries settle-drain and isolate-age columns, because a rate is not comparable without them.
memlab_external_stringsAttribute system / ExternalStringData — usually the largest class in a browser heap, and the one a retainer trace cannot explain. Names the source chunks by reading their content.
memlab_explain_deltaWHERE a heap grew, attributed to the object that owns the new bytes rather than to what they are. Production-only by default; flags a backing store that grew by a one-time capacity step.
memlab_dominator_chainFrom one node up to the accountable application object.
memlab_dominator_attributionGiven several candidate retainers, how much each one actually dominates — a zero refutes a hypothesis.
memlab_allocation_sitesWHO allocated these objects: live objects grouped by the JavaScript stack that allocated them (needs a capture recorded with allocation tracking, e.g. a .heaptimeline).
memlab_retained_byBytes retained ONLY through closure contexts, detached DOM, the DevTools console or event handlers: what removing every such retainer would free, with the largest classes. Filter any query or histogram the same way with retained_by.
memlab_dead_context_variablesCaptured variables no live code can read, heap-wide: a value kept alive only because it shares a closure Context with a sibling closure that is still alive. Ranked by what clearing them frees (a value counts only when that slot is the one thing holding it; one held only by several dead slots is listed with how many), grouped by scope; a dead slot whose value something else also holds (the shared Window) is left out unless include_shared. Needs a V8 15.6+ (Chrome 156+) capture.
memlab_probesSave an app's probes once (code, cap, expect flat/bounded) in a named set; ladder_probe, ab_compare and the battery run a set whose match is in the round's URL filter, with OK / VIOLATED per probe.
memlab_element_censusRetained React elements and fibers by component: fibers mounted / alternate / detached, elements by holder (mounted tree, closure, update queue, dev debug field…); per-rung growth with run_dir.
memlab_fiber_censusWhat the mounted React tree is made of per list item: rendered vs collapsed/virtualized items by subtree size, and each heavy child type per rendered item ("44 per item × 32 items"), with removal bytes; per-snapshot deltas with paths.
memlab_error_callsitesWhere retained Error objects were created, from the stack frames V8 captured (survives a truncated .stack); groups by top frames, names the JSX site of React _debugStack Errors.
memlab_rendered_text_auditUI text bugs read from React fibers, no pixels needed: [object Object], undefined, Invalid Date, an empty parameter (You added & ), unreplaced {name} / %s; by component, per rung and per A/B arm.
memlab_native_pin_costNative (browser) memory JS alone keeps alive, by pinner: a promise by its first .then, a closure by its function; per rung and per cycle with run_dir, per arm on an A/B round. What app_delta cannot see.
memlab_retained_errorsRetained Errors and error text by message template, with first app frame and whether only the DevTools console holds them; with run_dir the change per cycle and templates new since the first rung.
memlab_model_duplicatesRecords of one class that share an identity value (identity_path, e.g. __x_id._serialized): copies of a one-per-id model, where the extras are held and what they retain; one id across model types is listed apart, not as a copy; per-rung counts and change with run_dir.
memlab_scope_chainsChains of contexts of one function, each call pinning the previous call's scope through a captured closure: invisible to class counts. Flags the React Compiler dev hook-guard artifact (links only through t0..tN); per-rung lengths with run_dir. A scope with no module is labelled by its linking closure's script file and position.
memlab_retainer_traceThe shortest retainer path for one node; mode: "tree" shows every owner as a bounded tree (max_depth, max_nodes, max_siblings) ending at a root or the page global. A repeating multi-hop chain prints once with its count. On a minified build the path starts at the module holding the object; raw: true shows the registry hops above it. With no module on the path, it names the script file and position of the nearest closure.
memlab_retainer_summaryRetainer paths across many instances, clustered by shape. On a minified build each pattern starts at the holding module; raw: true keeps the registry hops.
memlab_referrer_summaryWho points at this, grouped by edge.
memlab_pinch_pointsSingle objects whose release would free the most.
memlab_dominator_subtreeWhat one object holds, expanded downward.
memlab_retainer_layersThe retention structure around a node, layer by layer.
memlab_trace_dominatorsDominator path for a set of nodes at once.