Meet a Java heap dump analyzer that looks for all kinds of memory problems proactively.

HIGH-LEVEL OVERVIEW

Your Java apps need more memory with every release. They crash suddenly with OutOfMemoryError. They spend a lot of time in garbage collection. What do you do?

The typical answers are: “increase memory”, “tune the GC” and, finally, “use some tool to see what’s inside that heap”. But too often these measures don’t work well. Available RAM may be limited or expensive. The GC may be unable to keep up even after much tuning. And tools just present you with a vast object graph and leave it up to you to make sense of it. Frankly, the situation with memory analysis hasn’t improved much in a decade. Can we do better? Enter JXRay – the first Java memory analysis tool that’s truly intelligent. It works by analyzing JVM heap dumps – memory snapshot files that can be generated on demand or when the JVM crashes with OutOfMemoryError.

WHAT MAKES IT DIFFERENT

Most other tools present a user with little more than rough memory contents, and let them make and test their guesses about it. In contrast, JXRay proactively looks for all kinds of known, well understood Java memory problems and gives you concrete, actionable findings. These results are carefully aggregated, so that all the bad objects managed by the same code are immediately visible. Thus, it becomes clear what code you need to change to save the biggest amount of memory. In unoptimized apps, it’s often enough to change 10-20 lines of code to save 20-30% of memory and/or greatly reduce GC pauses. And all this can be achieved in half an hour rather than days!

OTHER ADVANTAGES

  • Extremely scalable: processes 1-4 GB heap dumps in less than a minute, and can handle dumps of up to 256GB.
  • Doesn’t need to run on a machine that has a screen attached. Thus, JXRay can process big heap dumps “in place”, for example on a production machine where the dump was generated. Or it can be integrated in production to run automatically.
  • We have used JXRay to improve memory footprint of many open source projects (Apache Hive, Spark, Sentry, HBase, HDFS etc.), as well as many proprietary products. In other words, this tool is built, and continues to evolve, based on first-hand experience optimizing industrial Java applications.

TECHNICAL OVERVIEW

JXRay takes a JVM heap dump in .hprof format, analyses it and produces a report in rich HTML. The main advantages of JXRay are:

Detecting sources of memory waste instantly. JXRay analyzes a heap dump upfront for many known problems, such as memory leaks and various anti-patterns: duplicate strings and other objects, underutilized collections and arrays, overused boxed numbers, etc. Detecting such issues is especially important in Android apps, where memory is tight.

Recommendations on changing code. JXRay is the only memory profiling tool that provides concrete recommendations on how to change your code to address each detected problem.

Compact presentation. JXRay aggregates (merges) identical reference chains, repeating data fields (think linked lists), similar GC roots, etc. This makes even the biggest and most complex heaps comprehensible.  You can easily understand where most memory goes, and what code needs to be changed to make the biggest improvements.

Knowledge of internals. JXRay knows implementation details of the standard Java and Scala collections: maps (e.g. HashMap), lists (e.g. ArrayList), etc. That allows it to present a streamlined view of the heap, omitting the irrelevant collection internals. Furthermore, the tool accurately calculates how much memory is used by the implementation of collections vs their payload. It’s often surprising how much memory collections themselves need!

Offline tool. The fact that JXRay has no GUI and produces HTML reports has big advantages. You can easily run the tool on any machine, e.g. big “headless” machines in the cloud (including a production machine where the dump was generated). Later, anyone can look at the report from anywhere, send it out by e-mail, attach to a JIRA ticket, or share on the web.

Battle-hardened. JXRay has been used to identify and fix many real performance issues. We quickly found all sorts of problems that went undetected for years. See some Apache open source projects investigated and improved with JXRay.

To get a feeling of how the tool works, take a look at a few sample reports generated by JXRay.

If you would like to learn more about Java memory problems recognized by JXRay, why they are so common, and why they waste a lot of memory, check out the presentation below: