/memory-leak-detection
Detect and fix memory leaks using heap snapshots, memory profiling, and leak detection tools. Use when investigating memory growth, OOM errors, or optimizing memory usage.
$ npx -y skills add aj-geddes/useful-ai-prompts --skill memory-leak-detection --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/memory-leak-detection
Context preview
The summary Claude sees to decide when to auto-load this skill.
Detect and fix memory leaks using heap snapshots, memory profiling, and leak detection tools. Use when investigating memory growth, OOM errors, or optimizing memory usage.
SKILL.md
memory-leak-detection.SKILL.mdname: memory-leak-detection
description: >
Detect and fix memory leaks using heap snapshots, memory profiling, and leak
detection tools. Use when investigating memory growth, OOM errors, or
optimizing memory usage.
Memory Leak Detection
Table of Contents
- [Overview](#overview)
- [When to Use](#when-to-use)
- [Quick Start](#quick-start)
- [Reference Guides](#reference-guides)
- [Best Practices](#best-practices)
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:
| Guide | Contents | |---|---| | [Node.js Heap Snapshots](references/nodejs-heap-snapshots.md) | Node.js Heap Snapshots | | [Memory Leak Detection Middleware](references/memory-leak-detection-middleware.md) | Memory Leak Detection Middleware | | [Common Memory Leak Patterns](references/common-memory-leak-patterns.md) | Common Memory Leak Patterns | | [Python Memory Profiling](references/python-memory-profiling.md) | Python Memory Profiling | | [WeakMap/WeakRef for Cache](references/weakmapweakref-for-cache.md) | WeakMap/WeakRef for Cache | | [Memory Monitoring in Production](references/memory-monitoring-in-production.md) | Memory 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
Read more
name: memory-leak-detection description: > Detect and fix memory leaks using heap snapshots, memory profiling, and leak detection tools. Use when investigating memory growth, OOM errors, or optimizing memory usage.
Memory Leak Detection
Table of Contents
- [Overview](#overview)
- [When to Use](#when-to-use)
- [Quick Start](#quick-start)
- [Reference Guides](#reference-guides)
- [Best Practices](#best-practices)
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:
| Guide | Contents | |---|---| | [Node.js Heap Snapshots](references/nodejs-heap-snapshots.md) | Node.js Heap Snapshots | | [Memory Leak Detection Middleware](references/memory-leak-detection-middleware.md) | Memory Leak Detection Middleware | | [Common Memory Leak Patterns](references/common-memory-leak-patterns.md) | Common Memory Leak Patterns | | [Python Memory Profiling](references/python-memory-profiling.md) | Python Memory Profiling | | [WeakMap/WeakRef for Cache](references/weakmapweakref-for-cache.md) | WeakMap/WeakRef for Cache | | [Memory Monitoring in Production](references/memory-monitoring-in-production.md) | Memory 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
488 production-ready AI prompts, all following a standardized template with validated quality gates. Transform ChatGPT, Claude, and other AI assistants into expert consultants.
Repo: aj-geddes/useful-ai-prompts
Other skills on useful-ai-prompts.
- /ab-test-analysis
Design and analyze A/B tests, calculate statistical significance, and determine sample sizes for conversion optimization and experiment validation
Open skill - /access-control-rbac
Implement Role-Based Access Control (RBAC), permissions management, and authorization policies. Use when building secure access control systems with fine-grained permissions.
Open skill - /accessibility-compliance
Implement WCAG 2.1/2.2 accessibility standards, screen reader compatibility, keyboard navigation, and a11y testing. Use when building inclusive web applications, ensuring regulatory compliance, or improving user experience for people with disabilities.
Open skill - /accessibility-testing
Test web applications for WCAG compliance and ensure usability for users with disabilities. Use for accessibility test, a11y, axe, ARIA, keyboard navigation, screen reader compatibility, and WCAG validation.
Open skill - /agile-sprint-planning
Plan and execute effective sprints using Agile methodologies. Define sprint goals, estimate user stories, manage sprint backlog, and facilitate daily standups to maximize team productivity and deliver value incrementally.
Open skill - /alert-management
Implement comprehensive alert management with PagerDuty, escalation policies, and incident coordination. Use when setting up alerting systems, managing on-call schedules, or coordinating incident response.
Open skill

