heap-snapshot-analysis

Analyze V8 heap snapshots to diagnose memory leaks and trace object retention paths.

Updated Sep 3, 2026
One-click install
npx skills add https://github.com/az0512124155azz-sys/CodeForge --skill heap-snapshot-analysis-az0512124155azz-sys
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: heap-snapshot-analysis
Source: https://github.com/az0512124155azz-sys/CodeForge/tree/main/.github/skills/heap-snapshot-analysis
Command: npx skills add https://github.com/az0512124155azz-sys/CodeForge --skill heap-snapshot-analysis-az0512124155azz-sys

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Investigating memory leaks in Node.js and VS Code-style applications requires parsing massive .heapsnapshot files that often exceed JSON.parse limits, then manually diffing snapshots and tracing why objects survive garbage collection. This Skill provides parsing, comparison, and retainer-path helpers that make that investigation systematic. ## Core Features & Use Cases - Snapshot Parsing at Scale: Buffer-based and streaming parsers handle .heapsnapshot files from hundreds of megabytes to over 2 GiB without hitting Node Buffer limits. - Before/After Comparison: Diff two snapshots to surface top object groups by size and count growth, plus objects that only exist in the later snapshot. - Retainer Path Tracing: BFS over non-weak reverse edges reveals exactly what keeps a class of objects alive, skipping WeakMap red herrings. - Use Case: Given before/after snapshots of a chat session switch, compare object deltas, find that ChatModel instances survive GC, and trace the retainer path back to a RowCache template or singleton Map. ## Quick Start Analyze these two .heapsnapshot files to find which objects grew between them and trace what is retaining the leaked ChatModel instances.

Frequently Asked Questions about heap-snapshot-analysis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I analyze a V8 heap snapshot for memory leaks?▼

Parse the .heapsnapshot file with a Buffer-based parser, build a graph of nodes and edges, then trace non-weak reverse edges from suspect objects to GC roots. Comparing before/after snapshots by constructor group highlights which objects grew.

How to compare two heap snapshots in Node.js?▼

Load both snapshots, group nodes by type and constructor name, then diff counts and self sizes per group. The comparison reports top groups by size increase, count increase, and objects present only in the later snapshot.

Why does parsing a large .heapsnapshot file fail with ERR_FS_FILE_TOO_LARGE?▼

Node cannot create a Buffer larger than roughly 2 GiB, so full-file reads fail on very large snapshots. Switch to streaming scripts that locate section offsets and parse nodes, edges, and strings in chunks instead of raising --max-old-space-size.

What are retainer paths in heap snapshot analysis?▼

A retainer path is the chain of references from a GC root to an object that keeps it alive. Tracing non-weak reverse edges via BFS reveals why an object survives garbage collection; weak edges like WeakMap entries must be skipped since they do not prevent collection.

Can WeakMap references cause memory leaks in heap snapshots?▼

No. WeakMap entries appear as weak edges in retainer paths but do not prevent garbage collection, so they are red herrings during leak analysis. Always skip weak edges when tracing what retains an object.

What are common false retainers in VS Code heap snapshots?▼

DevTools debugger global handles, DevToolsLogger._aliveInstances from VSCODE_DEV_DEBUG_OBSERVABLES, and FinalizationRegistry self-references can all appear as retainers without being real application leaks. Verify these sources before attributing a leak to application code.