JAVA MEMORY ANALYZER THAT KNOWS WHAT TO LOOK FOR
From experience, almost every unoptimized Java application wastes between 10 and 50% of its memory due to common, easy-to-fix problems. Memory waste often directly correlates with long GC pauses. But do you have a tool that would recognize and pinpoint all these problems instantly?
JXRay is a memory analysis tool for Java that takes a JVM heap dump and produces a report in rich HTML format. The main advantages of JXRay are:
Detecting sources of memory waste right away. JXRay analyzes a heap dump upfront for many known, well understood problems. The most prevalent are memory leaks and various anti-patterns (duplicate strings and other objects, underutilizd collections and arrays, overused boxed numbers, etc.). This is especially relevant for Android applications, where memory is tight. All significant waste sources are highlighted, and you see them immediately.
Recommendations on changing code. JXRay is the only memory profiling tool that provides specific recommendations on how to change the code to address each of the specific detected problems.
Compact presentation. JXRay aggregates (merges) all identical reference chains, repeating data fields (think linked lists), similar GC roots, etc. The resulting compressed, clear view of even the biggest and most complex heaps allows you to easily understand where most memory goes, and what code manages it. Thus you can quickly figure out what classes and methods need to be changed to get the biggest memory improvement.
Knowledge of internals. JXRay knows the implementation details of most of the common Java and Scala collections: maps (e.g. java.util.HashMap), lists (e.g. java.util.ArrayList), etc. That allows it to present a streamlined view of the heap structure, omitting the irrelveant objects that make up collection internals. Furthermore, the tool accurately calculates how much memory is taken by the implementation of collections vs their payload - and it's often surprising how much memory collections themselves need.
Offline tool. While it may seem counterintuitive, 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, you can look at the report anywhere at any time, send it out by e-mail, attach to a JIRA ticket, or share on the wiki.
Tested in combat. JXRay has been used to identify and fix many real performance problems. We quickly found all sorts of problems that went undetected for years. See some Apache open source projects investigated and improved with 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 these presentation slides.
For in-depth understanding of how Java applications can waste memory, and how to prevent that, take a look at the following articles: