How do you diagnose a memory leak?
Memory leaks can be investigated using heap snapshots, heap comparisons over time, garbage-collection metrics, allocation profiling, and controlled load tests. A useful approach is to reproduce the growth pattern, take snapshots at different points, compare retained objects, and identify references preventing garbage collection. Monitoring RSS, heap used, heap total, and external memory can also provide useful clues.
Key Takeaways
- Heap snapshots are valuable for memory investigations.
- Compare snapshots over time.
- Look for unexpectedly retained objects and their references.
Knowledge Check
Which tool is particularly useful for investigating retained JavaScript objects?