All skills
chromedevtools avatar

/memory-leak-debugging

@46c3e05

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.

Use this Skill: https://skilld.dev/gh/chromedevtools/chrome-devtools-mcp/memory-leak-debugging

This session only. Nothing lands on disk.

referencescommon-leaks.md

≈454 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Common Memory Leaks

When analyzing retaining paths, dominator chains, or class diffs with Chrome DevTools MCP memory tools, look for these common patterns in the codebase:

1. Uncleared Event Listeners

Event listeners attached to global objects (like window or document) or long-living objects prevent garbage collection of the objects referenced in their callbacks.

Fix: Always call removeEventListener when a component unmounts or the listener is no longer needed.

2. Detached DOM Nodes

A DOM node is removed from the document tree but is still referenced by a JavaScript variable. While detachedness is a good signal for a memory leak, it's not always a bug. For example, websites sometimes intentionally cache detached navigation trees.

Fix: Signal the detached nodes to the user first. Ask the user first before nulling the references or changing the code, as the detached nodes might be part of an intentional cache. If confirmed as a leak, ensure variables holding DOM references are set to null when the node is removed, or limit their scope.

3. Unintentional Global Variables

Variables declared without var, let, or const (in non-strict mode) or explicitly attached to window remain in memory forever.

Fix: Use strict mode, properly declare variables, and avoid global state.

4. Closures

Closures can unintentionally keep references to large objects in their outer scope.

Fix: Nullify large objects when they are no longer needed, or refactor the closure to not capture unnecessary variables.

5. Unbounded Caches or Arrays

Data structures used for caching (like objects, Arrays, or Maps) that grow without limits.

Fix: Implement caching limits, use LRU caches, or use WeakMap/WeakSet for data associated with object lifecycles.

Source: SKILL.md on GitHub

No alerts16d4 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill provides instructions for diagnosing memory leaks using Chrome DevTools MCP tools. While functionally appropriate for its debugging purpose, it possesses an attack surface for indirect prompt injection because it processes untrusted data from web pages and heap snapshots.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 46c3e05. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 1 hour ago.

Activeupdated last month

README badge

README badge for chromedevtools/chrome-devtools-mcp/memory-leak-debugging