All skills
Skillintermediate
/find-leaks - Find Memory Leaks
Detect and diagnose memory leaks in the application.
Claude Code Knowledge Pack7/10/2026
Overview
/find-leaks - Find Memory Leaks
Detect and diagnose memory leaks in the application.
Steps
- Configure the application for leak detection with appropriate tooling
- Establish a baseline memory measurement at application startup
- Run a repetitive workload: process N requests, render N times, or execute N iterations
- Measure memory after each iteration to detect steady growth
- Force garbage collection between measurements to isolate true leaks
- Identify objects that grow in count across iterations without being released
- Trace the retention path: what is holding references to leaked objects
- Check common leak sources:
- Event listeners not removed on cleanup
- Closures capturing large scopes
- Growing caches without eviction
- Circular references preventing GC
- Timers and intervals not cleared
- For each leak, identify the source file, line, and the allocation site
- Suggest specific fixes: removeEventListener, WeakRef, cache size limits
- Verify the fix by re-running the leak detection scenario
- Report: leaks found, estimated memory impact, fix suggestions
Rules
- Run leak detection for at least 100 iterations to confirm a pattern
- Distinguish between expected memory growth and actual leaks
- Check both heap memory and native memory (buffers, file handles)
- Verify leaks are reproducible before reporting
- Consider the application lifecycle; some growth is expected during warmup
- Check for connection pool leaks (database, HTTP, WebSocket)
- Report the growth rate (bytes per iteration) for each detected leak