Memory analyzer tools are useful throughout the project lifecycle.
In design, we use them to compare different coding and design strategies to see the impact of each on memory usage. In development, they help us optimize our code. This is especially useful when writing applications for small devices, and also for applications that will run in the cloud. Memory usage is one of the criteria used when calculating cloud computing costs.
Most of all, they’re useful for monitoring and troubleshooting in production to ensure memory-related issues don’t cause poor performance or system failures.
Choosing the right tool depends on several factors: the application’s running environment, the purpose of the analysis, and also personal preference. In this article, we’ll look at some popular memory analyzers, and discuss which may be best depending on the circumstances.
Popular Memory Analyzer Tools
Let’s start by taking a look at six of the most popular memory analyzer tools.
1. HeapHero
HeapHero is a comprehensive utility for deep heap dump analysis. It’s part of the yCrash analysis suite, and has both a free and a paid option. HeapHero can be used in the cloud, installed on-premise, or used in automated workflows using REST APIs. HeapHero offers the following:
- Machine language diagnostics, which can pick up many memory-related issues automatically, and suggest solutions.
- An interactive list of objects sorted from largest to smallest, showing both shallow and retained heap usage. From this list, we can browse up and down the dominator tree to find parents and children. This is invaluable for finding memory leaks and identifying objects that use too much memory.
- An interactive histogram.
- An interactive list of garbage collection roots.
- Statistics and a breakdown of heap usage by generational heap spaces.
- Details of memory wastage.
- Thread details if required.
- OQL (Object Query Language) for advanced reporting.
- A facility to share interactive reports with other team members.
Data masking can be requested for sensitive heap dumps.
HeapHero is more than just a simple heap dump analyzer, integrating interactive reports and helpful suggestions with deep analysis.
See this video for a demonstration on how to analyze a heap dump with HeapHero.

Fig: Extract from a HeapHero Report
2. Eclipse MAT
Eclipse MAT is another powerful and popular heap dump analyzer.
It’s free and open source, and needs to be installed locally. For critical systems, it’s best not to install it on a production machine, since all heap dump analyzers are heavy on resources. Typically, it would be installed on a development machine or on a laptop.
It’s simple GUI interface and comprehensive features make it a popular choice.
It includes:
- An interactive leak suspect report;
- Ability to explore the dominator tree and GC roots
- Class Histogram
- OQL facilities
MAT can handle large dumps provided the machine it’s running on has sufficient RAM. For large systems, the heap dump may occupy as much as tens of gigabytes.
It was developed by the Eclipse foundation, and can be integrated with the Eclipse IDE.

Fig: Screenshot from Eclipse MAT
3. JHat
JHat is a heap dump analyzer included in older JDKs. In later versions, it’s discontinued in favor of JDK Mission Control. It’s still available, but may not continue to support dumps from newer JVMs in the future.
It’s often still used when working with older JDKs, since it needs no separate installation and is therefore immediately available. It produces an interactive report via a web browser.
Another reason it may still be used today is that it exposes low-level structures that are filtered out by newer heap dump analyzers, and this may occasionally be necessary for deep analysis.
It includes the ability to browse the dominator tree, and supports OQL. It does not work well with very large heap dumps.

Fig: Class Histogram Produced by JHat
4. JDK Mission Control
JDK Mission Control (JMC) is primarily a profiler rather than a heap dump analyzer. It allows us to look inside a running JVM and get details of its internal state, either in real time, or for a fixed period by using it to visualize recordings taken by Java Flight Recorder.
It was packaged with some versions of the JDK, but now it’s available as a free download. It’s important to get the right version of JMC for the Java version you have installed: read the JMC release notes to check which JVMs it will work with.
JMC’s memory tab and garbage collection tab give us insights into how much memory is used and how well GC is coping. We can see a class histogram, and zoom in on allocations to see what objects are being created. This is very helpful for debugging a memory leak.
In common with other profilers, JMC doesn’t give us the deep insights we can gain from a heap dump, such as browsing the dominator tree and using OQL.
It’s an excellent and powerful tool for gaining insights into a running program. It can also load a heap dump and produce a memory wastage report.

Fig: Memory Wastage Report Produced by JMC
5. VisualVM
VisualVM is also primarily a profiler. It was originally packaged with the earlier JDKs as JVisualVM, but it’s now available as free open source on GitHub.
It allows us to monitor various aspects of the JVM, including memory usage. A plug-in is available to let us monitor GC behavior.
VisualVM can initiate and analyze a memory dump, giving us statistics, the option to browse the dominator tree, and view a class histogram.
It’s not as powerful as some other tools, but it’s lightweight and very simple to use. VisualVM is a good starting point to give us direction when troubleshooting or optimizing, and let us know which areas need to be analyzed more fully with other tools.

Fig: Heap Dump Analysis in VisualVM
6. Android Studio Memory Profiler
Android Studio Profiler is a profiler specifically designed for use with Android applications. It’s an integral part of the Android Studio IDE, and it can be used to monitor both local and network applications.
It initially produces graphs of memory, CPU and network activity. Clicking on the memory lane allows us to see objects by class, and investigate them. We can zoom in on individual items, list them by depth of reference, and follow the reference chain. We can also search for activity leaks.
We can force garbage collection, or take a heap dump. Heap dumps can be submitted to tools such as HeapHero for deeper analysis.
This tool is always the first step in optimizing or troubleshooting Android applications.

Fig: Profiling with Android Studio
How to Choose the Right Memory Analyzer for a Task
Each of the tools we’ve mentioned are useful, but not necessarily for the same task.
If we need quick insights into a running JVM as a first step in troubleshooting, we would choose one of the profiling tools, whereas if we need deep analysis to solve a difficult problem, we would choose one of the heap dump analyzers.
The platform, such as Android, Linux or Windows, is also an important factor in our choice, as is the version of the JVM we’re working on, and the size of the application.
Personal preference also plays a part, but there are some situations where our tool of choice doesn’t have a particular feature we need to solve the current problem.
The flowchart below shows the steps we may take when choosing the right memory analyzer for a specific occasion.

Fig: Choosing a Memory Analyzer Page 1

Fig: Choosing a Memory Analyzer Page 2

Fig: Choosing a Memory Analyzer: Page 3
In summary:
- JHat is useful when working with older versions of the JDK where other tools aren’t available. We may also use it if we specifically need access to low-level structures.
- Android Studio Profiler is ideal for realtime monitoring of an android application.
- VisualVM is a simple, lightweight tool that’s ideal for a quick look at a running program.
- JDK Mission Control is useful for deeper insights into a running JVM.
- Eclipse MAT is a good choice for most heap dump analysis tasks, but lacks some of the useful features of HeapHero. Its ability to analyze large dumps depends on the RAM available on the machine where it’s installed.
- HeapHero is a good choice for deep analysis, machine learning suggestions, sharing interactive reports within the team, and incorporating heap dump analysis into automated workflows via REST APIs.
Conclusion
Monitoring memory usage is an important part of troubleshooting. It’s also useful when developing optimized applications.
There are a number of good memory analyzer tools available, each suited to particular situations.
The choice of tool depends on several factors, which we’ve explored in this article.

Share your Thoughts!