Skip to main content

Tool Reference

The server has about 150 tools, grouped by the question they answer. Each page below lists one group, with a line on when to use each tool. Within a group, the tools are in the order to try them, and a few tools are in more than one group. The pages are generated from the same index the server prints with memlab_tools.

GroupAnswersTools
Heap compositionWhat is this heap actually made of?45
Growth and leaksIs anything growing — and is it a leak?43
RetentionWho owns the growth / why is X retained?36
Measurement artifactsIs it real, or a measurement artifact?6
Detached DOM and listenersDetached DOM and event listeners6
Collections and cachesCollections and caches15
Strings and duplicationStrings and duplication8
Inspect objectsInspect or find specific objects17
Custom queriesNone of the above — ask the heap directly4
Sharing a captureSharing a capture outside its trust boundary1
Session and batchingSession, batching and write-ups18

Find a Tool​

You don't need to know tool names: describe what you want to find out, and the assistant picks a tool. To browse, ask the assistant to call memlab_tools:

  • With no arguments, it prints every tool by group, with when to use it.
  • With question (for example "growing", "retained" or "artifact"), it lists the groups that match.
  • With tool, it finds the tool's group. Add schema: true to print the tool's parameters.

From a shell, memlab-cli schema <tool> prints a tool's parameters (see Command Line).

Expose Fewer Tools​

Every tool the server exposes takes up room in the assistant's context, and most investigations use a few dozen. Start the server with MEMLAB_TOOLSETS set to a comma-separated list of groups, such as core or core,growth,retention, to expose only those, plus the few tools every session needs. memlab_tools({enable: "<group>"}) turns on more groups during a session.

core is a set of everyday tools: summaries, class histograms, largest objects, references and referrers, retainer traces, detached DOM, snapshot diffs and memlab_eval. The other group names are on each group's page.

For a session that only reads snapshots (no browser, no harness), start the server with MEMLAB_TOOLSET=analysis. It exposes 29 tools: the verdict table, memlab_validate_finding, memlab_counterevidence, memlab_report_lint and memlab_bound_evidence, the sweep, memlab_eval and memlab_eval_across, the retainer, cut and island tools, detached DOM, pending promises and retry loops, the collection diff, the finding index, the growth and coverage checks, memlab_feedback, and the session tools. That is about a quarter of the full tool list's schema size (about 140 KB instead of 590 KB). memlab_tools still lists every tool by question, and memlab_tools({enable: "memlab_timers"}) turns one more tool on (a group name turns on the group).

What Every Tool Accepts​

These conventions hold across the tools:

  • Any snapshot, without switching. A tool that reads one snapshot takes an optional snapshot: a loaded snapshot's handle, or a .heapsnapshot path loaded for that call only.
  • Sizes. Every byte-size filter takes a number of bytes or a size such as "1MB" or "500KiB" (KB is 1000 bytes, KiB is 1024).
  • Paging. Ranked lists end with "Showing a–b of N … Next page: offset: k". Pass offset for the next page. Ties are broken by node id, so a given offset always shows the same rows.
  • Shorter output. memlab_snapshots with max_name_length clips node names in every tool for the rest of the session, and table_format: "csv" prints tables as compact CSV.
  • Terse mode. memlab_snapshots({terse: true}), or MEMLAB_TERSE=1 at startup, makes every tool keep only headings, tables, verdict and warning lines, finding bullets and code. It drops explanatory notes, long prose, suggested next steps and the orientation menu, and prints tables without alignment padding. On one round this cut the leak report, detached DOM and listener reports together from about 15.5 KB to 6.6 KB.
  • Verdict rows. detail: "rows" on memlab_sweep, memlab_quick_diagnosis, memlab_collection_diff and memlab_diff_snapshots prints one row per finding (kind, key, per-rung count, Shape and last-interval Δ on a ladder, bytes, known family, owner) in one unpadded table, without the explanations and next-step calls; the sweep keeps its residual call. The default is still the full report. On a 3-million-node ladder this cut the four replies to between 29% and 44% of their full size.
  • JSON reports. memlab_leak_report, memlab_detached_dom, memlab_event_listener_leaks and memlab_react_update_queues take format: "json": the report as sections of tables (numeric cells parsed), verdicts, bullets and text, ready to pass to a script.
  • Structured results. The main list and lookup tools also return structuredContent: the same rows as JSON, with raw byte counts, the filters that applied and a pagination object, so a client can use the results without parsing tables.
  • Forgiving parameter names. A tool refuses a parameter it doesn't declare, and names the closest one it does. Common names are read as the one they mean, on every tool, and the reply says so: for example path and snapshot_path as file_path or snapshot, snapshots as paths, id as node_id, before/after as baseline/target, node_id as node_ids: [id], snapshot as paths: [snapshot], and run_dir (with optional rungs: indexes, cycle counts like "c50", or "first" / "last" / "settle") as the rung paths a tool without run_dir takes. A call is refused only when the meaning is ambiguous, such as an alias and the name it means given different values. A budget past its maximum, such as wait_ms or limit, is read as the maximum, with a note.
  • Short refusals. A refusal is a plain reply, not a protocol error. It names the parameter first, with a "did you mean", then lists the tool's parameters with their types (* marks the required ones). A value the schema rejects is checked before the call runs and gets one line per problem, such as `kind`: got "dev_only"; expected one of retainer-path | update-queue | …, instead of the client's dump of the whole input schema. Every refusal ends with the call that prints the full schema, memlab_tools({tool: "<name>", schema: true}).
  • Snapshot header. A reply starts with > Snapshot: … only when the call read that snapshot. A refusal, and a tool that reads no snapshot (such as memlab_finding_index), prints none.