Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
aj-geddes avatar

Memory Leak Detection

  • 507 installs
  • 305 repo stars
  • Updated March 4, 2026
  • aj-geddes/useful-ai-prompts

memory-leak-detection is a Claude Code skill that helps developers investigate rising heap usage, orphaned event listeners, and retained objects in long-running clients and services.

About

memory-leak-detection is a debugging skill from useful-ai-prompts for tracing memory growth in long-running clients and backend services before release or after performance complaints. It guides investigation of rising heap usage, orphaned event listeners, and retained object graphs that cause gradual memory bloat. Developers reach for memory-leak-detection when production or staging processes show climbing RSS or heap metrics and standard profiling has not isolated the retaining path.

  • Heap and allocation profiling
  • Listener and closure audits
  • Reproduction scenarios
  • Fix prioritization
  • Regression test ideas

Memory Leak Detection by the numbers

  • 507 all-time installs (skills.sh)
  • Ranked #87 of 596 Debugging skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill memory-leak-detection

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs507
repo stars305
Last updatedMarch 4, 2026
Repositoryaj-geddes/useful-ai-prompts

How do you debug memory leaks in production services?

Investigate rising heap usage, orphaned listeners, and retained objects before release or after performance complaints in long-running clients and services.

Who is it for?

Developers debugging gradual memory growth in long-running services or client apps ahead of release or after user performance reports.

Skip if: One-time CPU spikes, network latency issues, or greenfield projects with no observed memory growth symptoms.

When should I use this skill?

User reports rising heap usage, orphaned listeners, retained objects, or memory bloat in long-running clients or services.

What you get

Identified leak sources, listener cleanup fixes, retained object reports, and stabilized heap usage profiles.

  • Leak source identification
  • Listener cleanup recommendations

Files

SKILL.mdMarkdownGitHub ↗

Memory Leak Detection

Table of Contents

Overview

Identify and fix memory leaks to prevent out-of-memory crashes and optimize application performance.

When to Use

  • Memory usage growing over time
  • Out of memory (OOM) errors
  • Performance degradation
  • Container restarts
  • High memory consumption

Quick Start

Minimal working example:

import v8 from "v8";
import fs from "fs";

class MemoryProfiler {
  takeSnapshot(filename: string): void {
    const snapshot = v8.writeHeapSnapshot(filename);
    console.log(`Heap snapshot saved to ${snapshot}`);
  }

  getMemoryUsage(): NodeJS.MemoryUsage {
    return process.memoryUsage();
  }

  formatMemory(bytes: number): string {
    return `${(bytes / 1024 / 1024).toFixed(2)} MB`;
  }

  printMemoryUsage(): void {
    const usage = this.getMemoryUsage();

    console.log("Memory Usage:");
    console.log(`  RSS: ${this.formatMemory(usage.rss)}`);
    console.log(`  Heap Total: ${this.formatMemory(usage.heapTotal)}`);
    console.log(`  Heap Used: ${this.formatMemory(usage.heapUsed)}`);
    console.log(`  External: ${this.formatMemory(usage.external)}`);
// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
Node.js Heap SnapshotsNode.js Heap Snapshots
Memory Leak Detection MiddlewareMemory Leak Detection Middleware
Common Memory Leak PatternsCommon Memory Leak Patterns
Python Memory ProfilingPython Memory Profiling
WeakMap/WeakRef for CacheWeakMap/WeakRef for Cache
Memory Monitoring in ProductionMemory Monitoring in Production

Best Practices

✅ DO

  • Remove event listeners when done
  • Clear timers and intervals
  • Use WeakMap/WeakRef for caches
  • Limit cache sizes
  • Monitor memory in production
  • Profile regularly
  • Clean up after tests

❌ DON'T

  • Create circular references
  • Hold references to large objects unnecessarily
  • Forget to clean up resources
  • Ignore memory growth
  • Skip WeakMap for object caches

Related skills

How it compares

Use memory-leak-detection over general debugging skills when symptoms are gradual heap growth rather than crashes or logic errors.

FAQ

When should developers use memory-leak-detection?

Developers should use memory-leak-detection when heap usage climbs in long-running clients or services, especially before a release cut or after user performance complaints about gradual slowdown.

What symptoms does memory-leak-detection address?

The memory-leak-detection skill targets rising heap usage, orphaned event listeners, and retained objects that cause progressive memory bloat in production or staging environments.

Debuggingbackendtesting

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.