The Memory Analyzer is a fast and feature-rich Java heap analyzer that helps us find memory leaks and reduce memory consumption. It works with multi-GB heaps of various formats like IBM core dumps, IBM PHD (Portable Heap Dumps) heapdumps, Sun HPROF heapdumps. The Memory Analyzer provides efficient memory leak detection and footprint analysis with powerful reporting capabilities including memory leak suspects, system overview, top components (by retained heap) and more. Memory Analyzer (MA) is based on the open source tool MAT with IBM value add.The Memory Analyzer is a free tool available through the IBM Support Assistant.
Why do we need to use Memory Analyzer?
Because Java provides automatic memory management, a lot of developers believe that Java applications do not have memory leaks. Garbage Collection in Java does relieve us from the mundane duties of allocating, tracking and freeing objects in the Java heap. But Garbage Collection can only free objects that do not have any reference from the active state of the program (stacks and registers) or other objects – and typical memory leaks are caused by objects that are no longer required in the heap, but persist in the heap due to a reference to them.
Memory leak analysis looks into a few key entities.
– What is the object (e.g. a HashMap) holding all the leaking objects i.e. leak container.
– What are the objects getting added to the leak container i.e. leak unit.
– Who is holding the leak container in memory? What are the object types and package names of objects on the chain of references from a root object to the leak container i.e. owner chain.
Debugging Memory leak is not an exact science, analysis will point out suspects. Likelihood of leak depends upon the size of the leaking data structure, drop size, number of leaking units and the number of instances of objects in the ownership context graph nodes.