3. What's the difference between monitoring heap "used" vs "committed"?
Three key heap metrics:
Heap Used: Actual memory consumed by Java objects currently in heap (live objects + garbage awaiting collection). Example: 3.4 GB used = application allocated 3.4 GB for objects, arrays, data structures. Alert on this metric for OutOfMemoryError prevention (Used >85% of Max = Warning).
Heap Committed: Memory reserved by JVM from OS (guaranteed available for heap allocation). Always >= Used, <= Max. Example: Used 3.4 GB, Committed 4 GB = JVM reserved 4 GB from OS, currently using 3.4 GB. JVM grows committed automatically as heap fills (starts at Min, grows toward Max).
Heap Max: Maximum heap size configured via
-Xmx
JVM argument. Example:-Xmx4g
= Max 4 GB. Cannot exceed this value—OutOfMemoryError thrown if Used reaches Max.
Why monitor both:
- Used >85% of Max: Proactive alert before heap exhaustion
- Committed growing rapidly: Indicates JVM allocating more memory (potential memory leak, investigate if Committed approaching Max)
- Used close to Committed: Heap fully utilized within reserved space (JVM will attempt to grow Committed, or trigger GC if at Max)
Example scenario: -Xms1g -Xmx4g
(Min 1 GB, Max 4 GB). Application starts: Committed 1 GB, Used 0.5 GB. After 2 hours: Committed 2.5 GB (JVM auto-grew), Used 2.3 GB (normal growth). After 6 hours: Committed 3.8 GB, Used 3.7 GB (approaching Max). Alert fires "Heap Used 92% of Max" (3.7 GB / 4 GB) → Investigate memory leak or increase Max to 8 GB.
Related Questions
See all FAQs: [Troubleshooting Overview][]