heap-snapshot-inspection

Analyze Chromium heap snapshots to diagnose memory leaks in Chrome, Node.js, and Electron.

4.4k|1.3k|Updated Jan 23, 2012
One-click install
npx skills add https://github.com/paulirish/dotfiles --skill heap-snapshot-inspection
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: heap-snapshot-inspection
Source: https://github.com/paulirish/dotfiles/tree/main/agents/skills/heap-snapshot-inspection
Command: npx skills add https://github.com/paulirish/dotfiles --skill heap-snapshot-inspection

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires heap-snapshot-toolkit.

What problem does it solve?

Investigating memory leaks in Chromium-based applications requires parsing large, opaque heap snapshot files, which is slow and error-prone without dedicated tooling. This Skill provides a structured CLI workflow to summarize, diff, and inspect heap snapshots so you can pinpoint leaking objects and their retainers.

Core Features & Use Cases

  • Heap Summaries: Get high-level statistics on total heap size, V8 heap breakdown (code, strings, arrays), and native memory.
  • Snapshot Diffing: Compare a baseline snapshot against a later one to identify which object classes are growing in count and size.
  • Object & Retainer Inspection: List objects by class (e.g., Detached DOM nodes), inspect individual objects by ID, and trace retainer chains to understand why objects stay alive.
  • Use Case: After noticing your Electron app's memory grows with each window open, capture snapshots before and after, run a diff to find growing classes, then inspect retainers to find the event listener keeping objects alive.

Quick Start

Ask the AI to analyze a heap snapshot file by running a summary and diff against a baseline to identify which objects are leaking.

Frequently Asked Questions about heap-snapshot-inspection

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

FAQPage Schema
How do I analyze a Node.js heap snapshot for memory leaks?

Capture two heap snapshots around the suspected leak, then run the diff command to see which object classes grew in count and size. Follow up by listing objects of the growing class and inspecting their retainers to find what keeps them alive.

How to compare two heap snapshots to find leaks?

Use the diff command with a baseline snapshot and a later snapshot as arguments. The output ranks classes by size delta and count delta, highlighting the top 20 growing classes so you can focus on the largest contributors.

What are detached DOM nodes in heap snapshots?

Detached DOM nodes are elements removed from the document tree but still referenced by JavaScript, preventing garbage collection. They are a common leak source in web apps, and you can find them by listing objects with the class filter set to Detached.

Does the heap-snapshot CLI work with Chrome and Electron snapshots?

Yes, the CLI parses any Chromium-format .heapsnapshot file, including those captured from Chrome DevTools, Node.js, and Electron. It uses heap-snapshot-toolkit for parsing and requires Node.js 24 or later to run.

Why should I force garbage collection before taking a heap snapshot?

Running GC before capture removes objects that are already unreachable, so the snapshot only contains genuinely retained memory. This makes diffing more accurate and prevents transient allocations from appearing as false leaks.