Top 5 Heap Dump Analyzers for Fixing OutOfMemoryError

A heap dump is a snapshot of Java heap memory at a given moment. We’d use it to diagnose memory-related issues, such as memory leaks, poor garbage collection performance, and OutOfMemoryError.

Since a heap dump is a large binary file, we need a tool to analyze its contents. There are several excellent on-premise or online heap dump analyzers available.

In this article, we’ll look at a few of them, and discuss their strengths and weaknesses.

Offline vs Online Heap Dump Analyzers

Most heap dump analyzers are downloadable desktop applications, designed to be used by members of the technical team on their own PCs. A few, however, are available online, allowing a heap dump to be uploaded to the cloud for analysis.

We need to bear in mind that heap dumps may contain sensitive information, such as credit card numbers. They also may be very large: typically around 20% bigger than the used heap size.

There are a few pros and cons to both online and offline analysis tools.

Online Vs Offline Dump Analyzers: Pros and Cons

Online Heap Dump AnalyzersOffline Heap Dump Analyzers
Pros: 

1. Available from anywhere on demand.

2. No need to find, download and install a tool

3. Since they run on large servers, they can handle very big dumps

4. Good tools such as HeapHero allow interactive reports to be shared with the team
Pros: 

1. Confidential dumps don’t need to leave the organization. However, this still needs to be managed carefully, as they often need to be moved to the technician’s machine, which may not be 100% secure

2. May sometimes be faster, as large dumps don’t need to be uploaded to the cloud
Cons: 

1. Unless the tool allows data masking before uploading, storing it online could potentially result in security breaches

2. Large dumps may take time and bandwidth to upload. This can be mitigated by first compressing the file, if the tool allows this.
Cons: 

1. It’s usually not a good idea to run them on production machines, since they are resource-hungry.

2. For large dumps, the PC running the tool needs to be extremely powerful.Some offline analyzers don’t cater for large dumps

The Top 5 Java Heap Dump Analyzers

The choice of heap dump analyzer depends on many factors, such as the software you already have, whether you have very large dumps, and also personal preferences. 

See this article to find out several ways to take a heap dump.

Here are 5 popular tools worth considering.

1. HeapHero

HeapHero has a free version, which works online and includes a comprehensive interactive report, part of which is shown in the image below.

Fig: Section of a HeapHero Report

The report includes:

  • MML diagnostics if problems are detected.
  • An interactive list of objects sorted by usage. It shows both shallow and retained heap, and allows us to interactively browse the dominator tree of each object.
  • Histogram.
  • GC roots.
  • Usage report by heap area.
  • Memory wastage report.
  • Optional thread analysis.

We can use OQL (Object Query Language) for advanced reporting.

For sensitive dumps, data masking can be requested.

APIs are also available to include heap analysis in CI/CD pipelines, or integrate it with management tools such as Jira. This feature isn’t offered by any of the other dump analyzers we’ve looked at.

There is also a paid version, which caters for very large dumps, has the option of an on-premise version, and includes more comprehensive REST APIs.

HeapHero is a very quick way of investigating memory issues. It’s also a deep analysis tool that goes beyond a simple heap dump analyzer.

For a demonstration of how to find a memory leak with this tool, see How to Analyze a Heap Dump Fast.

2. Eclipse MAT

Eclipse MAT is a stand-alone application, which can be downloaded for free.

It produces a leak suspect report, and allows the user to explore the dominator tree and GC roots.  It can cater for large dumps provided the technician’s machine has enough RAM to process them.

It’s simple to use, very popular and has a comprehensive set of features. See the screenshot below.

Fig: Eclipse MAT

It includes Object Query Language (OQL) for deeper analysis. MAT is the tool of choice for many DevOps specialists, since it’s easy to use, memory-efficient and fast.

3. IBM HeapAnalyzer

IBM HeapAnalyser is primarily aimed at IBM JVM users, but can be made to work fairly well with other Java platforms. As at time of writing, it won’t run on newer versions of HotSpot Java.

It’s downloadable for free, and has an intuitive GUI interface. It has all the tools necessary for diagnosing memory issues, but it’s a bit slower and more memory-hungry than MAT.

It can handle large dump files if the DevOps machine is powerful enough.

The screenshot below shows the GUI interface.

Fig: IBM HeapAnalyzer

4. Java Mission Control (JMC)

Java Mission Control was bundled with the earlier versions of JDK, but now needs to be downloaded separately. It’s a multi-purpose profiler designed primarily to be used with Java Flight Recorder, but it also has the facility to upload and analyze a heap dump.

The version of JMC must be compatible with the installed JVM version. 

It’s better for diagnosing memory wastage than for finding memory leaks, but does include a referrer chain and a histogram.

JMC requires a lot of memory, and may crash with larger dumps. It’s still a popular tool, since it includes much more than a heap analyzer, and many organizations keep it both as a profiler and a dump analyzer.

The screenshot below shows the GUI interface.

Fig: JMC interface

5. VisualVM

VisualVM is an open-source all-purpose profiler, originally available with older JDK versions as JVisualVM.

It can either connect to a running JVM to perform diagnostics, or it can upload heap dump files. It’s fast and lightweight, making it a good choice for quick initial analysis of a problem.

We can see memory usage statistics, view objects sorted by size and explore outgoing and incoming references. A class histogram is available.

For deeper analysis, HeapHero or MAT offer more choices, but it’s a handy tool to have, and adequate for solving most memory issues.

VisualVM is often a good tool for a first look at JVM issues, since it can allow us to look inside a running application, and take thread or heap dumps for further analysis if we need them.

The interactive GUI interface is shown in the screenshot below.

Fig: VisualVM Heap Dump Analysis

Conclusion

In this article, we’ve looked at five popular heap dump analyzers. We’ve also looked at the pros and cons of online heap dump analyzers as opposed to desktop tools.

HeapHero is the most feature-rich of the tools we’ve investigated, followed closely by Eclipse MAT. IBM HeapAnalyzer is a good choice for IBM users.

JMC and VisualVM are useful, because they can perform other profiling tasks as well. VisualVM in particular is a good lightweight addition to the DevOps toolbox.

HeapHero has the added advantage in that it can integrate with management tools and the CI/CD pipeline to automate monitoring and diagnostics.

Share your Thoughts!

Up ↑

Index

Discover more from HeapHero – Java & Android Heap Dump Analyzer

Subscribe now to keep reading and get access to the full archive.

Continue reading