Node.js & V8 Memory Leak / CPU Spike Investigation
Analyze heap snapshots, unclosed event listeners, and runaway closures causing Node.js OOM crashes.
Identify and resolve memory retainers, unclosed event listeners, runaway closures, and CPU event-loop blocking in Node.js services.
Execution Workflow Procedure
Ordered steps the coding agent executes when performing this skill.
Inspect Heap Retention Paths
Analyze heap snapshot metrics to trace which objects in Old Space are prevented from garbage collection.
Identify Leak Vectors
Inspect global maps, uncleared setInterval timers, lingering EventEmitter listeners, and stream backpressure bottlenecks.
Implement Weak References & AbortControllers
Refactor listeners to use AbortController signals and replace unbounded Maps with LRU caches or WeakMaps.
Agent Safety Guardrails & Anti-Hallucination Rules
- DO NOT simply increase --max-old-space-size to hide a monotonic memory leak.
- DO NOT perform CPU-intensive synchronous regex or crypto loops on the main Node.js event loop.
Expected Output Format
Leak retainer breakdown and leak-free refactored code.
Domain Verification Checks
Example Agent Invocations
Install / Configure This Skill
# Place in .cursorrules or create .cursor/rules/nodejs-memory-leak-cpu-investigation.mdc # Trigger: Whenever you perform node.js & v8 memory leak / cpu spike investigation --- name: nodejs-memory-leak-cpu-investigation description: Diagnose Node.js heap leaks, unclosed event listeners, and event-loop blocking issues. version: 1.0.0 compatibility: [Cursor, Claude Code, Cline, Roo Code, Antigravity] --- # Node.js & V8 Memory Leak / CPU Spike Investigation ## Objective Detect and eliminate memory retainers, uncleaned event listeners, and event loop blocking operations in Node.js applications. ## Workflow 1. **Retainer Analysis**: Identify objects accumulating in V8 Old Space from heap snapshots. 2. **Leak Vector Elimination**: Remove lingering event listeners using `AbortController` and replace unbounded caches with TTL LRUs. 3. **Backpressure Validation**: Ensure streams respect pipeline backpressure.
Need a quick one-time prompt for chat?
Try the Node.js & V8 Memory Leak / CPU Spike Investigator — a lightweight version designed for 1-click copying directly into Claude, ChatGPT, or Cursor chat.
SprintKit Workflow Integrations
Complementary tools and checklists to pair with this agent workflow.
Related Agent Skills
Explore related procedural workflows in this discipline.
API Performance Bottleneck & N+1 Query Optimization
Diagnose slow database queries, serialization bottlenecks, and memory churn in sluggish API endpoints.
Production Exception & Stack Trace Root-Cause Analysis
Systematic investigation workflow for diagnosing production exceptions and constructing verified patches.
Strict TypeScript Type Safety & Soundness Audit
Audit TypeScript code for type safety, type narrowing, generics, mutation traps, and runtime boundary validation.