PM-03 // Memory & Performance
A SaaS production backend suffered recurring Out-Of-Memory (OOM) crashes every 5.5 to 6 hours as RSS heap climbed past 1.4GB. The internal team had resorted to a cron job rebooting the server every 4 hours.
The incident flow, timings and root cause are real. Client and agency identities are not disclosed; identifying details such as dates, amounts and volumes have been generalized.
Incident Summary
A SaaS production backend suffered recurring Out-Of-Memory (OOM) crashes every 5.5 to 6 hours as RSS heap climbed past 1.4GB. The internal team had resorted to a cron job rebooting the server every 4 hours.
Business & Technical Impact
API crashing 4 times daily from Out-Of-Memory (OOM), dropped WebSocket sessions, mobile app disconnects.
Incident Timeline
- T+00h · Chronic Issue Escalated — Client escalated the memory leak after 3 weeks of failed internal triage and cron workarounds.
- T+01h · V8 Heap Snapshot Differential — Captured differential heap snapshots at baseline (85MB) and T+3h (740MB); inspected via Chrome DevTools.
- T+02h · Root Cause: Dynamic Event Listeners — Identified notificationService.on("event") registered inside per-request middleware without cleanup (240,000 leaked closures).
- T+03h · Singleton Refactor & Stream Drain — Refactored event emitters into application-scoped singleton brokers with proper EventEmitter.setMaxListeners limits.
- T+04h · Validation: Flat Memory Curve — Executed 100,000 synthetic requests under stress; heap stabilized at flat 110MB with zero leak.
Root Cause Analysis (5 Whys)
Per-request middleware dynamically attached event listeners to a global EventEmitter without invoking .off() or AbortSignal cleanup, preventing V8 garbage collection of request contexts.
TMA SWAT Resolution & Hotfix
1. Eliminated per-request event subscriptions in favor of a singleton Redis pub/sub dispatcher. 2. Configured Node.js --max-old-space-size and GC logging flags. 3. Added process.on("warning") monitor to immediately catch MaxListenersExceededWarning.
Permanent Mitigations
• Integrated automated memory leak regression tests via autocannon into GitHub Actions. • Configured Prometheus alerts detecting monotonic RSS memory growth over 30-minute windows.
All technical reviews and interventions are covered under our Confidentiality and Engagement Agreement (NDA).
Trend Master Akademi Studio & Labs
B2B White-Label Engineering Desk | Tel: +90 534 371 35 73 | Email: info@trendmasterakademi.com
Address: Akdeniz Mah. Sehit Fethibey Cad. Heris Tower No: 55 Ic Kapi No: 091 Konak / Izmir