Systematic Memory Leak Hunter
Systematically identify and fix memory leaks in a production application using heap snapshots and allocation tracking
You are a performance debugging specialist. Help me systematically find and fix a memory leak in my application: **Symptoms:** [DESCRIBE — e.g., "Memory grows from 200MB to 2GB over 24 hours, then OOM kills the process"] **Runtime:** [RUNTIME — e.g., "Node.js 20 / Python 3.12 / Java 21 / Go 1.22"] **Application type:** [TYPE — e.g., "Express API server / React SSR / Background job processor"] **Already tried:** [WHAT_YOU_TRIED — e.g., "Restarted the process, checked for obvious event listener leaks"] Guide me through this debugging process: **Phase 1: Reproduce** - Exact steps to create a reproducible leak scenario - How to measure baseline memory (commands and tools) - Load generation script to accelerate the leak **Phase 2: Capture** - How to take heap snapshots at intervals (exact commands) - How to enable allocation tracking without significant overhead - What metrics to monitor during the capture window **Phase 3: Analyze** - How to compare heap snapshots to find growing objects - How to identify the retainer chain (what's keeping objects alive) - Common leak patterns specific to my runtime: - [Runtime-specific patterns, e.g., closures over large scopes, event emitter accumulation, timer references, global caches without eviction] **Phase 4: Fix** - Code pattern for each identified leak type with before/after examples - How to verify the fix (expected memory profile shape) - Preventive patterns to avoid similar leaks in the future **Phase 5: Monitor** - Metrics to set up for ongoing leak detection - Alert thresholds and escalation rules - Periodic heap snapshot automation for early detection For each phase, provide exact commands, code snippets, and expected output.
How to Use This Prompt
- 1Copy the prompt template above
- 2Paste into Claude, ChatGPT, or Cursor
- 3Replace [bracketed placeholders] with your specific project details
- 4Iterate on the AI output to refine and customize the results
More Debugging Prompts
Related debugging templates from the vault
Network Request Waterfall Analyzer
Use this prompt to network request waterfall analyzer with AI assistance
Stack Trace Decoder and Fixer
Use this prompt to stack trace decoder and fixer with AI assistance
Systematic Bug Diagnosis
Get structured help diagnosing a bug you cannot figure out
Error Message Decoder
Understand cryptic error messages and stack traces
You Might Also Like
Prompts from other categories that share similar tags
Memory Usage Profiling Guide
Use this prompt to memory usage profiling guide with AI assistance
React Rendering Performance Fix
Fix unnecessary re-renders and optimize React component performance
React Server Component Data Pattern
Implement efficient data fetching patterns with React Server Components
Next.js Performance Optimization
Optimize a Next.js application for Core Web Vitals and loading speed
Keep Exploring the Vault