Software Engineer
harddebugging-memory-leaks
How do you debug a memory leak in an application?
Answer
A memory leak is memory that’s no longer needed but still referenced.
**Approach:**
- Reproduce and measure (RSS/heap growth).
- Capture heap snapshots / dumps.
- Compare snapshots to find retained objects.
- Identify unexpected references (caches, global lists, event listeners).
- Fix and add regression tests/alerts.
**Interview tip:** mention that caches need eviction (LRU/TTL) and listeners must be unsubscribed.
Related Topics
DebuggingPerformance