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

HIGH-LEVEL OVERVIEW

Your Java apps need a bigger heap with every release. They leak memory and crash 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. Available RAM may be limited or expensive. The GC may be slow 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

Unlike most other tools, 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 bad objects managed by the same code are clearly visible. Thus, you see immediately what code you need to change to save the maximum amount of memory. In unoptimized apps, it’s often enough to change 10-20 lines of code to reduce memory footprint by 20-30% and/or greatly shorten 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 512GB.
  • Doesn’t need to run on a machine that has a screen attached. JXRay can process a heap dump “in place”, for example on a production machine where that dump was generated. Or it can be made a part of CI and run automatically.
  • We have used JXRay to find memory leaks, improve GC and memory of open source projects (Apache Hive, Spark, Sentry, HBase, HDFS, Azkaban etc.), as well as many proprietary products. This tool was built, and continues to evolve, based on first-hand experience optimizing industrial Java applications.

TECHNICAL OVERVIEW

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

Detecting sources of memory waste instantly. JXRay analyzes a 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 gives concrete recommendations on how to change your code to address each detected problem.

Compact presentation. JXRay aggregates (merges) identical reference chains, repetitive 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, e.g. HashMapArrayList etc. That allows it to present a streamlined view of the heap, omitting irrelevant collection internals. Furthermore, JXRay accurately calculates how much memory is used by the implementation of collections vs their payload. It’s often surprising how much memory such “container” data structures need!

Offline tool. JXRay has no GUI, runs once and produces an HTML report. Thus you can easily use it on any machine, including big “headless” machines in the cloud. Later, anyone can look at the report from, 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: