Key Heap Metrics: Shallow vs. Retained Size
Distinguish between "Shallow Heap" (memory consumed by an object itself) and "Retained Heap" (total memory freed if an object and its exclusively held dependents are garbage collected), crucial for pinpointing true memory hogs.
The top 3
- Shallow vs. Retained: When to Use Which: Shallow size identifies intrinsically large objects, while retained size is crucial for pinpointing memory leaks by revealing the total memory an object prevents from being garbage collected.
- Why Retained Size Dominates Leak Detection: Retained size is the most vital metric for memory leak detection as it uncovers objects acting as "gatekeepers," preventing large graphs of otherwise unreachable objects from being freed by the garbage collector.
- Top 3 Objects with High Retained Size in OOMs: High retained size often points to static collections, unbounded caches, or unclosed resources, which are common culprits behind OutOfMemoryError scenarios.
Sources
Open the full topic