Memory Analyser, Eclipse Galileo Feature #5

Memory Analyser, Eclipse Galileo Feature #5

With all the great work going on in the Eclipse Run-time space, like the EMF Runtime, RAP, Birt Charting Engine, ECF, Jetty and of course Equinox, I sometimes forget that Eclipse started as an excellent platform for tools. The Eclipse Memory Analyzer project reminded me just how good Eclipse tools are.

All week I have been counting down the top 10 Galileo features that I’m most excited about. Number 5 on my list is the Eclipse Memory Analyzer (MAT). This project was first released in December 2008 and is now part of the Galileo release train. MAT provides a large selection of features to help you analyze Java heap dumps to understand your memory consumption and help remove leaks.

As you may have noticed, many of my posts focus on the simplicity of the new features. The MAT project is no different. Getting started with the Memory Analyzer is a simple 3 step process:

  1. Install the MAT tools (optionally install the charting engine too). (Hint: Use p2 for this)
  2. Grab a heap dump:I simply used the JMap tool available with my JDK. 12345 was the PID of my Eclipse process.
    $ jmap -heap:format=b 12345
  3. Open the Heap Dump
    JMap generates a file called heap.bin

Some of the notable features include:

  • The reporting of memory leak suspects:leak_suspects
  • Calculating Retained Sizes (How much memory is used, rooted at a particular object):retainedHeap
  • Track the pointers back to the GC (garbage collection) roots:path_to_gc
  • Thread and Stack information:threads
  • SQL-like language for querying the heap:query

    Shout-outs for this go to Andreas Buchen and the entire Memory Analyzer team. Thank-you for guys for such an awesome (and unbelievably useful) tool!

    Note: I got these examples by running the memory analyzer on Eclipse, after analyzing a 670 Meg heap. It’s unbelievable, but the MAT heap was only 21 Megs. 21 Megs used to analyze over 1/2 a Gig. How cool is that?