All skills
Skillintermediate
/profile-memory - Profile Memory Usage
Capture and analyze memory usage of the application.
Claude Code Knowledge Pack7/10/2026
Overview
/profile-memory - Profile Memory Usage
Capture and analyze memory usage of the application.
Steps
- Detect the application runtime: Node.js, Python, Java, Go, or browser
- Configure the profiling tool: Node.js --inspect, Python tracemalloc, Java VisualVM
- Start the application with memory profiling enabled
- Capture an initial heap snapshot as the baseline
- Execute the workload or user scenario to profile
- Capture a second heap snapshot after the workload completes
- Compare the two snapshots to identify memory growth
- Analyze retained objects: which objects are keeping memory alive
- Identify the top 20 memory consumers by retained size
- Check for common leak patterns: growing arrays, event listeners, closures, caches
- Calculate total memory usage: heap used, heap total, RSS, external
- Generate a memory profile report with growth analysis and object counts
Rules
- Take multiple snapshots at intervals to detect gradual memory growth
- Run the profiled scenario multiple times to distinguish leaks from normal allocation
- Focus on retained size, not shallow size, for identifying actual memory impact
- Include GC metrics: frequency, pause time, reclaimed memory
- Profile under realistic load conditions, not idle state
- Do not profile with debugger attached in production
- Report memory in human-readable units (KB, MB, GB)