Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

memory-leak-debugging — Claude Code skill: leaks and setup

Finds memory leaks in JavaScript and Node.js with Chrome DevTools MCP. Use it to investigate high memory use, OOM errors, and heap snapshots.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add ChromeDevTools/chrome-devtools-mcp --skill memory-leak-debugging -a claude-code
Open on GitHub

What memory-leak-debugging does

This skill guides memory-leak investigations in JavaScript and Node.js. It separates browser-side issues from Node.js issues, captures heap snapshots before and after repeatable actions, compares them, and helps locate classes and objects that keep growing.

The workflow uses Chrome DevTools MCP tools such as take_heapsnapshot, get_heapsnapshot_summary, compare_heapsnapshots, and APIs for retainers, dominators, and object details. It recommends repeating the same interaction 10 times, restoring the page state, then closing loaded snapshots with close_heapsnapshot.

Advanced tools require the MCP server to start with --memoryDebugging, so check that before beginning an investigation. Do not read raw .heapsnapshot files directly; use MCP summaries and comparisons first. The analysis covers detached DOM nodes, closures, globals, event listeners, and caches that keep growing.

What it helps with

  • locate a leak in the browser or Node.js
  • capture baseline, target, and final heap snapshots
  • compare snapshots to find growing classes
  • trace retainers and dominator chains back to application code
  • inspect objects held by DOM nodes and event handlers

Example prompts for the agent

  • Investigate a memory leak in this JavaScript app. Repeat the user flow 10 times, capture snapshots before and after it, then compare the results.
  • Use `get_heapsnapshot_summary` and `compare_heapsnapshots` to find classes that grow between the baseline and target snapshots.
  • Trace why this object is still reachable with `get_heapsnapshot_retainers`, `get_heapsnapshot_retaining_paths`, and `get_heapsnapshot_dominators`, then close the loaded snapshots.

How to install memory-leak-debugging

1Skills CLI (Vercel)

npx skills add ChromeDevTools/chrome-devtools-mcp --skill memory-leak-debugging -a claude-code

2Manually: put the files in place

~/.claude/skills/memory-leak-debugging/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/memory-leak-debugging/

From the same set6

The whole set →

Similar

search official anthropics Runs parallel queries across connected MCP tools and synthesizes the findings into a single answer. Helpful when decisions or notes are scattered across chat, email, and storage. Claude Code CX Codex Cursor +1 5,000installs create-tldr-page official github Builds a tldr page out of a command's docs: one-line summary, upstream link and 5–8 example invocations. GitHub Copilot 8,800installs start official anthropics Checks connected MCP servers and surveys bio-research tools. Helps researchers get oriented with the plugin before starting a project. Claude Code CX Codex Cursor +1 4,900installs claude-certification rohitg00 Walks you through one of four Claude certification tracks: teaches the lesson, runs the lab, checks your artifacts. Useful when you are preparing for an exam and want a tutor instead of a reading list. Claude Code CX Codex Cursor +1 3,300installs prompt-master nidhinjs This skill writes and improves prompts for a named AI tool. Use it when a rough request needs to become a ready-to-paste prompt for Claude Code, Cursor, or another supported tool. Claude Code CX Codex Cursor +1 3,900installs portless vercel-labs Assigns local dev servers stable names like myapp.localhost instead of port numbers. Claude Code CX Codex Cursor +1 5,900installs setup-matt-pocock-skills Matt Pocock This skill configures a repository for Matt Pocock's engineering skills by setting its issue tracker, triage labels, and domain docs layout. Run it before using the other skills. Claude Code 1,052,851installs to-tickets Matt Pocock Turns a plan, spec, or conversation into small end-to-end tickets with explicit blockers. Use it to agree on the work breakdown before tickets go to a tracker. Claude Code 711,230installs

Questions about memory-leak-debugging

How do I install memory-leak-debugging in Claude Code?

Run npx skills add ChromeDevTools/chrome-devtools-mcp --skill memory-leak-debugging -a claude-code, then run the same command again. After installation, check ~/.claude/skills/memory-leak-debugging/SKILL.md.

What does memory-leak-debugging do?

The skill investigates memory leaks in JavaScript and Node.js through Chrome DevTools MCP. It captures and compares heap snapshots, follows retaining paths, and helps identify objects that remain reachable.

What is required for advanced heap snapshot analysis?

The MCP server must start with --memoryDebugging. After the investigation, close loaded snapshots with close_heapsnapshot to release memory held by the MCP server.

Source text

SKILL.md · Apache-2.0
---
name: memory-leak-debugging
description: Diagnoses and resolves memory leaks in JavaScript/Node.js applications. Use when a user reports high memory usage, OOM errors, or wants to capture, compare, or inspect heap snapshots with Chrome DevTools MCP memory tools.
---

# Memory Leak Debugging

This skill provides expert guidance and workflows for finding, diagnosing, and fixing memory leaks in JavaScript and Node.js applications using Chrome DevTools MCP tools.

## Prerequisites

Advanced memory debugging tools (`compare_heapsnapshots`, `get_heapsnapshot_details`, etc.) are only available when the server is started with the `--memoryDebugging` flag. First check if these tools are available; if not, try to read the MCP configuration file to check if `--memoryDebugging` is enabled.

## Core Principles

- **Prefer MCP memory tools:** Do NOT attempt to read raw `.heapsnapshot` files directly, as they are extremely large and will consume too many tokens. Use the Chrome DevTools MCP heap snapshot tools to summarize, compare, and inspect snapshots.
- **Isolate the Leak:** Determine if the leak is in the browser (client-side) or Node.js (server-side).
- **Common Culprits:** Look for detached DOM nodes, unhandled closures, global variables, event listeners not being removed, and caches growing unbounded. _Note: Detached DOM nodes are sometimes intentional caches; always ask the user before nulling them._
- **Close Loaded Snapshots:** Heap snapshots can be large. After completing an investigation, use `close_heapsnapshot` for each loaded snapshot to release memory held by the MCP server.

## Workflows

### 1. Capturing Snapshots

When investigating a frontend web application memory leak, utilize the `chrome-devtools-mcp` tools to interact with the application and take snapshots.

- Use page-scoped tools like `click`, `navigate_page`, `fill`, etc. (specifying `pageId`) to manipulate the page into the desired state.
- Revert the page back to the original state after interactions to see if memory is released.
- Repeat the same user interactions 10 times to amplify the leak.
- Use `take_heapsnapshot` (with `pageId`) to save `.heapsnapshot` files to disk at baseline, target (after actions), and final (after reverting actions) states.

### 2. Comparing Snapshots

Once you have generated `.heapsnapshot` files using `take_heapsnapshot`, compare them with Chrome DevTools MCP memory tools.

- Start with `get_heapsnapshot_summary` for each snapshot to confirm that the files load and to compare high-level totals.
- Use `compare_heapsnapshots` to compare baseline and target snapshots. Start without `classIndex` for the summary diff, then request detailed class diffs only for suspicious growth by specifying `classIndex`.
- Use the summary output from `compare_heapsnapshots` before drilling into specific node IDs.

### 3. Inspecting Retainers and Dominator Chains

When a class or object type grows unexpectedly, inspect the retaining chain and dominators with the MCP tools before changing code.

- Use `get_heapsnapshot_class_nodes` to list instances of the suspicious class.
- Use `get_heapsnapshot_retainers`, `get_heapsnapshot_retaining_paths`, `get_heapsnapshot_dominators`, and `get_heapsnapshot_edges` to understand why representative nodes are still reachable.
- Use `get_heapsnapshot_object_details` with a specific `nodeId` to retrieve detailed object metadata (size, type, distance, and DOM detachedness).
- Use `get_heapsnapshot_duplicate_strings` when string growth dominates the diff.
- Read [references/common-leaks.md](references/common-leaks.md) for examples of common memory leaks and how to fix them after the retaining path points at application code.

### 4. Advanced Analysis and Categorized Filters

Use built-in MCP memory tools and filters to pinpoint specific leak categories directly without external tools.

- Use `get_heapsnapshot_details` or `get_heapsnapshot_class_nodes` with `filterName` to target common leak causes:
  - `objectsRetainedByDetachedDomNodes`: Identifies detached DOM elements retained in memory.
  - `objectsRetainedByEventHandlers`: Identifies objects kept alive by unremoved event listeners.
  - `objectsRetainedByContexts`: Identifies objects trapped in closures or execution contexts.
  - `objectsRetainedByConsole`: Identifies objects retained by console logging.

© ChromeDevTools · Apache-2.0 · ChromeDevTools/chrome-devtools-mcp

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor