Memory Analyzer Reports contain various sections such as Overview, Dominator Tree, Threads, Duplicate Classes, GC Roots, Unreachable Objects, System Properties, OQL… In this post let’s learn about Class Histogram. What information is presented in this section? What patterns should you look for in a Class Histogram? What actions can you take directly from this view? And more importantly How to use this Class Histogram to troubleshoot Memory problems?
What is Class Histogram?
A class histogram is a summary of all the classes that are present in the JVM along with the number of objects and the total memory size they occupy. It provides a quick way to understand which object types are consuming memory, which is particularly helpful in identifying memory leaks or excessive memory usage by specific object types.

Fig: Class Histogram Reported by HeapHero
Class Histogram contain following information reported in table format
1. Class Name: Fully qualified name of the class that is present in the memory. Example: java.lang.String
2. Instance Count: Total number of object instances that is present for this class. Example: 10,477
3. Shallow Size: The total amount of memory occupied directly by all instances of this class. It does not include the memory consumed by referenced objects. Example: 2.39MB
4. Retained Size: The total memory that would be freed if all instances of this class and everything reachable only through them were removed. This includes the class’s shallow size and the size of all objects it exclusively retains. Example: 12.46MB
Need more clarity? Shallow Size and Retained Size can be tricky to grasp. To understand it better, you may watch this video clip: Shallow Size vs Retained Size
Key Features of Class Histogram
The Class Histogram section in the memory analyzer tool, equips you with a range of capabilities to analyze heap dumps efficiently. Below are the features of Class Histogram in the memory analyzer tool HeapHero.

Fig: Class Histogram in HeapHero Tool
1. Search: You can use this feature to search the classes by class name. In the figure above, you can see the ‘ycrash’ is entered as the search criteria (i.e. #1), all classes containing that keyword are filtered and displayed. You can use this feature to quickly locate memory consuming classes specific to your application.
2. Sorting: Each column (Object Count, Shallow Size, Retained Size) in the Class Histogram can be sorted, refer to #2 in the above figure. This feature facilitates you to identify what are the largest memory consuming classes and spot classes with the highest object count.
3. Static Variables: The ‘Statics’ section under the ‘Actual Data’ pane (on the right side), displays all static variables of the selected class along with their actual values. This can be helpful when you try to investigate the memory held by static references.
4. General Overview: The ‘Statics’ section under the ‘Actual Data’ pane (on the right side), displays general information about this class, such as its object Id, total size it occupies, classloader which loaded this class… This view offers general context but is typically less useful for deep analysis.
5. Class Reference Insights: Clicking on the ‘… more’ hyperlink next to a class name, opens a dropdown menu, as shown below:

Fig: Class Deep Dive Capabilities
This menu allows you to explore detailed reference relationships for the selected class. Among the options, two are particularly valuable:
a. Incoming References: Shows all objects that are referencing this class. This is especially useful when diagnosing memory leaks, as it helps you identify what is keeping the class or its instances alive.
b. Outgoing References: Lists all child objects that the selected class is referencing. This view helps you understand why the class might be consuming a large amount of memory.
6. Group By: This option lets you organize the class histogram using different grouping strategies. Available ‘Group By’ options are:
- Class Name (default)
- Super Class
- Class Loader
- Package
While this feature offers additional flexibility for exploring heap structure, it’s not typically essential for deep memory analysis.
How Class Histogram Used for Troubleshooting Memory Problems?
Class Histogram can be used in the following manner to isolate memory problems:
1. Spot High-Level Memory Usage: The Class Histogram offers a quick overview of which classes are consuming the most memory in your application. By listing all loaded classes along with their instance counts, shallow sizes, and retained sizes, you will be able to identify memory heavy classes at a glance. This high-level visibility allows you to narrow down your focus to specific classes that are either highly populated or retain significant memory, serving as a first checkpoint before diving into more detailed reference or dominator tree analysis.
2. Analyze Growth Over Time: A single Class Histogram gives you a snapshot of memory usage. By comparing histograms from multiple heap dumps taken at different times allows you to spot growth trends. If a class’s object count or retained size steadily increases over time, it may indicate unbounded data structures, unclosed resources, or poor cleanup logic. This trend-based analysis is especially useful in identifying slow leaks that may not immediately trigger OutOfMemoryError but degrade performance over extended periods.
3. Track Memory to Application Functional Areas: By searching for class names or package prefixes in the Class Histogram, you can tie memory usage directly to specific parts of your application. For instance, if you know a particular feature or module uses a class named com.myapp.cache.CacheEntry, you can inspect its memory footprint after users interact with that feature. This lets you correlate memory behavior with application logic and usage patterns.
4. Check for ClassLoader Leaks: Java applications that redeploy frequently or use modular architectures (like OSGi or web apps) are prone to classloader leaks. The Class Histogram allows you to group objects by classloader, helping you detect classes loaded by old or duplicate classloaders that should have been unloaded. If you see a large number of objects still associated with a stale classloader, it indicates those objects and the classloader itself are being retained unnecessarily.
What are the limitations of the Class Histogram?
While the Class Histogram is a powerful starting point for heap dump analysis, it has following limitations:
1. It doesn’t explain why objects are retained: The histogram shows how many objects of each class exist and how much memory they consume, but it doesn’t tell you what is preventing those objects from being garbage collected. You won’t see the root cause or reference chain that is keeping them alive.
2. Can be misleading for diagnosing leaks: A class having a high retained size or object count does not always indicate a memory leak. For example, java.lang.String or byte[] might appear at the top simply because they are used heavily in your application and not because they are leaking.
Along with Class Histogram you need to use tools like “Dominator Tree“, “Incoming & Outgoing References” to diagnose memory leaks.
Conclusion
Class Histogram offers a fast, high-level view of which classes consume the most memory in your application. It helps you spot memory-heavy objects, track growth trends, and tie memory usage back to specific features. While it doesn’t explain why objects are retained, it’s a powerful first step in your memory analysis workflow.
