
Heap Snapshot Analysis
Finds JavaScript memory leaks in heap snapshots and explains why objects stay alive.
Install
npx skills add meta/memlab --skill memlab-analyze-heap-snapshot -g -a claude-code -y- Repository
- meta/memlab5.1k
- Category
- Engineering
- Updated
- 4d ago
- License
- MIT
- Context cost
- Mediumabout 2,017 tokens
- Runs scripts
- No, instructions only
What it does
Analyze 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.
Analyze a JavaScript heap snapshot with memlab
memlab parses a V8 or Hermes heap snapshot into a queryable graph and answers questions about it: what fills the heap, what keeps growing, and which chain of references keeps an object alive.
1. Get the tools
-
MCP tools available (names start with
memlab_): use them directly. -
No MCP tools: use
memlab-cli, which runs the same tools from a shell. Onecallruns several tools in one server session, so load the snapshot and analyze it in the same command:npx -y -p @memlab/mcp-server memlab-cli call \ memlab_load_snapshot '{"file_path":"/abs/path/app.heapsnapshot"}' \ memlab_quick_diagnosis '{}' \ memlab_auto_investigate '{}'Each
callstarts a new server and reloads the snapshot. For an investigation with many steps, keep one server running instead; see references/memlab-cli.md. -
If the user wants the MCP server set up permanently, suggest the memlab plugin, which also installs these skills:
claude plugin marketplace add meta/memlabthenclaude plugin install memlab@memlab(Claude Code), orcodex plugin marketplace add meta/memlabthencodex plugin add memlab@memlab(Codex). For the server alone, give themclaude mcp add memlab -e NODE_OPTIONS=--max-old-space-size=8192 -- npx -y -p @memlab/mcp-server memlab-mcp(Claude Code) or the JSON config in the MCP server docs. Keep--max-old-space-size=8192or higher: without it, large snapshots are refused.
