Fixing leaks overview
Fixing = break the unexpected retention path + prevent recurrence.
Pattern → fix map
Section titled “Pattern → fix map”| Leak | Fix |
|---|---|
| Global store | Module scope → bounded cache or external store with TTL |
| Timer | Store id, clearInterval on teardown |
| Listener | removeEventListener or AbortController |
| DOM | Don’t hoard elements; null refs in arrays |
| Closure | Minimize captured scope |
| Cache | LRU + max size |
Verify the fix
Section titled “Verify the fix”- Re-run reproduction soak test
- Snapshot diff — delta should plateau
- Monitor staging 24–48h before prod