memlab-analyze-heap-snapshot
O que ela faz
Ele usa a ferramenta memlab para ler heap snapshots do Chrome, Node.js, Electron ou React Native e rastrear por que a memória continua crescendo. É para desenvolvedores que investigam problemas de memória ou travamentos em aplicações JavaScript.
Quando usar
- ✓Quando você tem um arquivo de heap snapshot e quer saber o que está usando a memória.
- ✓Quando a memória da sua aplicação JavaScript não para de crescer ou ela fica sem memória.
- ✓Quando você suspeita de elementos DOM desconectados ou de um cache crescendo em uma aplicação web.
Link da skill
https://github.com/meta/memlab/blob/main/plugins/memlab/skills/memlab-analyze-heap-snapshot/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Aqui está o app.heapsnapshot do meu servidor Node. Descubra o que continua crescendo na memória e sugira uma correção.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
O agente carrega o snapshot no memlab, executa as ferramentas de diagnóstico rápido e de investigação, e rastreia a cadeia de referências que mantém os objetos vivos. Em seguida, sugere correções com base nesses achados.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do 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
Perguntas frequentes
Onde eu consigo um heap snapshot?
Uma skill separada explica como capturar snapshots no Chrome, Edge, Node.js, Electron ou React Native.
Precisa de alguma configuração especial?
A skill pode rodar o memlab pela linha de comando com npx, caso as ferramentas do memlab não estejam configuradas como servidor.
Ele explica por que um objeto continua na memória?
Sim. Ele rastreia a cadeia de referências que mantém o objeto vivo.
Detalhes
Descrição original do autor
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
Popularidade
- Estrelas no GitHub
- 5,1 mil
- Posição no ranking
- #15055
- Licença
- MIT
- Atualizada em
- 31/10/2026
Comentários
- …
Mais skills deste repositório
memlab-capture-heap-snapshots
5,1 milOrienta seu agente a capturar heap snapshots de JavaScript em um navegador, Node.js, Electron ou React Native, para que você possa estudar o uso de memória.
memlab-find-web-leaks
5,1 milAjuda seu agente a encontrar vazamentos de memória em uma página web, executando um teste roteirizado de uma interação e lendo os relatórios de vazamento que ele produz.
memlab-memory-tests
5,1 milAjuda seu agente a escrever testes automatizados que detectam vazamentos de memória, para código Node.js ou para fluxos de navegador executados na integração contínua.
Skills parecidas
diffs
394 milPermite que seu agente gere um diff real e compartilhável das edições, como link de visualização ou arquivo de imagem, em vez de um resumo escrito à mão.
coding-agent
394 milAjuda seu agente a passar um trabalho grande de programação para o Codex, Claude Code ou OpenCode em segundo plano e acompanhar o andamento.
gh-issues
394 milAjuda seu agente a encontrar issues do GitHub, escolher quais resolver e abrir pull requests com correções, acompanhando os comentários de revisão.