memlab-analyze-heap-snapshot
하는 일
memlab 도구로 Chrome, Node.js, Electron, React Native의 힙 스냅샷을 읽고, 메모리가 계속 늘어나는 이유를 추적합니다. JavaScript 앱의 메모리 문제나 충돌을 쫓는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓메모리가 무엇을 쓰고 있는지 알고 싶은 힙 스냅샷 파일이 있을 때.
- ✓JavaScript 앱의 메모리가 계속 늘어나거나 메모리가 부족해질 때.
- ✓브라우저 앱에서 분리된 DOM 요소나 계속 커지는 캐시가 의심될 때.
스킬 링크
https://github.com/meta/memlab/blob/main/plugins/memlab/skills/memlab-analyze-heap-snapshot/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 Node 서버에서 가져온 app.heapsnapshot이 있어요. 메모리에서 계속 늘어나는 것을 찾고 해결책을 알려 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트가 memlab에 스냅샷을 불러오고, 빠른 진단과 조사 도구를 실행한 뒤, 객체를 살아 있게 하는 참조 체인을 추적합니다. 그 결과를 바탕으로 수정 방법을 제안합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
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.
2. Get the snapshot
memlab_load_snapshottakes a local absolute path. If only<path>.gzexists, pass<path>and the server decompresses it. Download remote snapshots first.- For a file over about 1 GB, call
memlab_snapshot_headerfirst. It reads node and edge counts without parsing the graph and says whether the snapshot will load. - One snapshot shows what is in memory. To show what grows, you need two
or more snapshots taken from the same page or process while an interaction
repeats. If the user has none, see the
memlab-capture-heap-snapshotsskill or the memlab docs.
3. Triage
memlab_load_snapshotwith the path. Read the quick diagnosis it returns.- In parallel (all analysis tools are read-only once a snapshot is loaded):
memlab_quick_diagnosis: summary, top objects, class histogram, duplicated strings.memlab_auto_investigate: top retainers with retainer chains and severity, pinch points, unbounded caches, pending promises, known framework leak patterns.
memlab_app_heapto split the heap into application data, bundle source and engine internals before blaming the app for the total.- Note whether it is a browser or a Node.js heap; DOM tools only apply to browser snapshots.
4. Follow the matching path
Pick the path that fits the triage result. Each path is a short tool sequence in references/investigation-paths.md.
| Triage shows | Path |
|---|---|
| Many duplicated or huge strings | A: String waste |
| Detached DOM elements (browser) | B: DOM leaks |
| A class with very many instances, or one object retaining >5% of the heap | C: Object accumulation |
| Large closures in retainer chains | D: Closure leaks |
| Large non-built-in globals | E: Global variables |
| Many callback/listener/handler objects | F: Listener accumulation |
Many identical Error objects |
G: Repeated errors |
| Metric, cache key or record field with huge value cardinality | H: Cardinality explosion |
| Only one snapshot, need a growth guess | I: Single-snapshot growth signals |
| Three or more snapshots in order | J: Trend across snapshots |
| Huge detached tree in a browser snapshot, possibly from DevTools | K: Real leak or dev artifact |
5. Explain the retention
For the suspect object:
memlab_retainer_tracewith itsnode_id: the shortest path from a GC root. Useexpand: truewhen the interesting frame is hidden in an elided run.memlab_retainer_layerswith the samenode_idbefore proposing a fix. It lists every independent retaining path; cutting one edge frees nothing if another path still holds the object.memlab_closure_inspectionwhen a closure (or a suspended async function) is in the chain: it shows the captured variables and their s
자주 묻는 질문
힙 스냅샷은 어디서 얻나요?
Chrome, Edge, Node.js, Electron, React Native에서 스냅샷을 캡처하는 방법은 별도의 스킬이 다룹니다.
특별한 설정이 필요한가요?
memlab 도구가 서버로 설정되어 있지 않다면, 스킬은 npx로 명령줄에서 memlab을 실행할 수 있습니다.
객체가 메모리에 남아 있는 이유도 설명해 주나요?
네. 그 객체를 살아 있게 하는 참조 체인을 추적합니다.
상세 정보
작성자의 원본 설명
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.
repo: meta/memlab
인기도
- GitHub 스타
- 5.1k
- 순위
- #15055
- 라이선스
- MIT
- 업데이트
- 2026. 10. 31.
댓글
- …
이 저장소의 다른 스킬
memlab-capture-heap-snapshots
5.1k에이전트가 브라우저, Node.js, Electron, React Native에서 JavaScript 힙 스냅샷을 찍도록 안내해, 메모리 사용을 분석할 수 있게 합니다.
memlab-find-web-leaks
5.1k에이전트가 웹 페이지에서 상호작용 하나를 스크립트 테스트로 실행하고 누수 보고서를 읽어 메모리 누수를 찾도록 돕습니다.
memlab-memory-tests
5.1k에이전트가 메모리 누수를 잡아내는 자동 테스트를 작성하도록 돕습니다. Node.js 코드나 지속적 통합에서 실행되는 브라우저 흐름이 대상입니다.