Diagnostic step 1
Produce time-series heap snapshots and use heapdiff to identify retained object types and their retaining paths; automate snapshot capture under normal load and after a restart.
Generated Oct 3, 2026, 12:35:03 AM
Produce time-series heap snapshots and use heapdiff to identify retained object types and their retaining paths; automate snapshot capture under normal load and after a restart.
Search codebase for EventEmitter.on/addListener and setInterval/setTimeout calls inside request handlers or modules initialized per-request; refactor to attach listeners once at process start or ensure removal on request end (use emitter.removeListener or emitter.off and clearInterval).
Wrap third-party clients to a single shared instance when possible, and if a library creates listeners per usage, contact maintainer or add cleanup by calling provided close/destroy functions on request completion.
Add listener leak detection during development: process.setMaxListeners and checks for increasing counts, and deploy memory limit restarts as a temporary mitigation while fixing code.
If the leak source is a native addon or opaque third-party module, collect reproducible minimal test and escalate to a senior developer or the module author with heap snapshots and reproduction steps; avoid speculative rewrites in production without backups and blue/green deployment capability.