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.
| Group | Answers | Tools |
|---|---|---|
| Heap composition | What is this heap actually made of? | 45 |
| Growth and leaks | Is anything growing — and is it a leak? | 43 |
| Retention | Who owns the growth / why is X retained? | 36 |
| Measurement artifacts | Is it real, or a measurement artifact? | 6 |
| Detached DOM and listeners | Detached DOM and event listeners | 6 |
| Collections and caches | Collections and caches | 15 |
| Strings and duplication | Strings and duplication | 8 |
| Inspect objects | Inspect or find specific objects | 17 |
| Custom queries | None of the above — ask the heap directly | 4 |
| Sharing a capture | Sharing a capture outside its trust boundary | 1 |
| Session and batching | Session, batching and write-ups | 18 |
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. Addschema: trueto 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.heapsnapshotpath 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". Passoffsetfor the next page. Ties are broken by node id, so a given offset always shows the same rows. - Shorter output.
memlab_snapshotswithmax_name_lengthclips node names in every tool for the rest of the session, andtable_format: "csv"prints tables as compact CSV. - Terse mode.
memlab_snapshots({terse: true}), orMEMLAB_TERSE=1at 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"onmemlab_sweep,memlab_quick_diagnosis,memlab_collection_diffandmemlab_diff_snapshotsprints 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_leaksandmemlab_react_update_queuestakeformat: "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 apaginationobject, 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
pathandsnapshot_pathasfile_pathorsnapshot,snapshotsaspaths,idasnode_id,before/afterasbaseline/target,node_idasnode_ids: [id],snapshotaspaths: [snapshot], andrun_dir(with optionalrungs: indexes, cycle counts like"c50", or"first"/"last"/"settle") as the rung paths a tool withoutrun_dirtakes. 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 aswait_msorlimit, 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 asmemlab_finding_index), prints none.