Class Histogram: Top Memory-Consuming Classes

The Class Histogram provides a summary of all classes in the JVM, listing instance counts and total memory sizes, which helps quickly identify object types consuming the most heap.

The top 3

  1. Top 3 Classes Often Dominating JVM Heap: The classes `char[]` (backing Strings), `byte[]` (for buffers), and `java.lang.String` itself frequently appear at the top of class histograms, indicating significant memory consumption for raw data and text. [6, 10, 13, 15]
  2. 3 Essential Metrics in Class Histograms for OOM: Beyond just class names, the 'Instance Count' (how many objects), 'Shallow Size' (memory of the object itself), and critically, 'Retained Size' (total memory freed if an object is removed) are key for diagnosing OutOfMemory errors. [1, 2, 6]
  3. Top 3 Patterns: Class Histogram Memory Leak Clues: Look for a continuously growing instance count or retained size of specific classes over time, static collections or unbounded caches holding objects indefinitely, and unreleased event listeners or improperly used ThreadLocal variables as prime indicators of memory leaks. [6, 8, 9, 12]

Sources

Open the full topic