/memlab:memlab-capture-heap-snapshotsfrom MemLab
Captures JavaScript heap snapshots (.heapsnapshot) from Chrome, Edge, Puppeteer, Playwright, Node.js, Electron, or React Native (Hermes) for memory analysis with memlab. Supports single snapshots for memory inspection and series snapshots for leak detection.
Ships in MemLab. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A heap snapshot is a full dump of a JavaScript heap: every object, the
references between them, and their sizes. memlab, Chrome DevTools and the
memlab MCP server all read the same .heapsnapshot format.
By hand: DevTools → Memory → Heap snapshot → Take snapshot, then right-click the snapshot → Save.... DevTools runs garbage collection before each snapshot. Use a profile without extensions (or a guest window): extensions add their own objects to the page's heap.
From an agent, with the memlab MCP server: start the browser with
--remote-debugging-port=9222 --user-data-dir=/tmp/chrome-memlab, then call
memlab_capture with out_dir and a label. Chrome 136 and later ignore
--remote-debugging-port on the default profile, so the separate
--user-data-dir is required; a fresh profile also has no extensions. It also captures the page's dedicated workers, which a page snapshot
never includes. list_targets: true lists the pages it can attach to, and
url_filter picks one. A saved capture can later be referred to as
checkpoint:<label> wherever a snapshot path is accepted.
From Puppeteer or Playwright test code (Chromium only): use a CDP session. See references/capture-code.md for a copy-paste helper that runs garbage collection and streams the snapshot to a file.
require('v8').writeHeapSnapshot() writes a snapshot into
the current directory and returns the file name. Pass a path to choose it.node --heapsnapshot-signal=SIGUSR2 app.js, then run kill -USR2 <pid>
each time you want a snapshot.node --heapsnapshot-near-heap-limit=3 app.js (Node.js 14.18+/15.1+). It
writes up to 3 snapshots as the heap approaches its limit.node --inspect app.js, open
chrome://inspect, and use the Memory tab as in a browser.dumpNodeHeapSnapshot() from @memlab/core writes a
snapshot to a temp folder and returns its path.Writing a snapshot pauses the process and can temporarily need about as much memory again as the heap itself. Don't take one from a production server that is already close to its memory limit unless you can afford the pause.
v8.writeHeapSnapshot(), or start the
app with --inspect and attach from chrome://inspect.Open the debugger for the app (React Native DevTools) and take a heap snapshot from its Memory panel. memlab reads Hermes snapshots too.
memlab run --scenario <file> and memlab snapshot --scenario <file> drive
a page in Chromium and save s1.heapsnapshot (baseline), s2.heapsnapshot
(after the action) and s3.heapsnapshot (after undoing it) under
$(memlab get-default-work-dir)/data/cur/. See the memlab-find-web-leaks
skill for writing the scenario.
rung_00_c000.heapsnapshot, rung_01_c010.heapsnapshot, ... memlab's
series tools read the cycle count from that naming.Then analyze them with memlab_sequence_analysis or memlab_leak_report
(paths in order), or diff two of them with memlab_diff_snapshots. The
memlab-analyze-heap-snapshot skill covers the analysis.
A heap snapshot contains every string in memory: tokens, cookies, user data,
API responses. Treat it as sensitive. memlab anonymize --snapshot <in> --output <out> (or the MCP tool memlab_anonymize_snapshot) writes a copy
with user data redacted that still works for analysis. Run it again with
--audit-only on the output to see anything left in the clear before you
share it.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub meta/memlab --plugin memlab4 skills in this plugin
/memlab-analyze-heap-snapshotAnalyze JavaScript heap snapshots (.heapsnapshot files from Chrome, Edge, Node.js, Electron or React Native/Hermes) with memlab to find memory leaks, explain why objects stay in memory, and suggest fixes. Use when the user shares or mentions a heap snapshot, asks why memory or heap size keeps growing, sees an out-of-memory crash, detached DOM elements, a growing cache or listener count, or wants to compare snapshots taken before and after a change. Works through the memlab MCP server tools (memlab_*) or, without MCP, the memlab-cli command from the @memlab/mcp-server npm package./memlab-find-web-leaksFind memory leaks in a web app with memlab. Write a test scenario (url, action, back) that drives the page in Chromium through Puppeteer, run `memlab run`, read the clustered leak traces, and fix the code that keeps detached DOM elements, unmounted React components or other objects alive. Use when the user asks to check a page, component, modal, dialog, route or user flow for memory leaks, to write a memlab scenario, to set up memory leak tests for a web app, or to find out why memory is not released after a UI interaction is undone./memlab-memory-testsWrite automated memory leak tests with memlab. Use it for Node.js unit tests that assert an object was garbage collected (takeNodeMinimalHeap, tagObject, hasObjectWithClassName), for browser leak tests in CI that run a memlab scenario through @memlab/api and fail when leaks are found, and for checking heap snapshots from Playwright, Cypress or Puppeteer tests. Use when the user wants a regression test for a memory leak, asks how to assert that memory is released, or wants memory leak checks in Jest, Mocha, node:test or a CI pipeline.Other plugins' skills for the same job