Digital Edition

SYS-CON.TV
Using Eclipse Memory Analyzers
Identify leak suspects

Eclipse Session at Cloud Expo

The garbage collector is primarily responsible as a collector to reclaim objects that are no longer used by the application. This is an automatic memory management invented by McCarthy. The garbage collector collects unreferenced objects, objects that are not reached by the reference chain. The starting point of the analysis is the Garbage Collection Root (GCR), which are objects that are reachable by the VM. Objects that are nonreachable are garbage collected, whereas objects that are reachable are sustained in memory. GCR is very useful in identifying memory leaks and the reference chain from an arbitrary object to GCR tells about the suspects.

The Eclipse Memory Analyzer is a fast, feature-rich Java heap analyzer that helps to identify memory leakage. This project was initially released in December 2008 and is now part of the Galileo release train. The Eclipse Memory Analyzer (MAT) provides a large selection of features to help in analyzing a single snapshot of heap. MAT can be used to identify memory leaks using a single click.

Heap Dump - Shallow Heap, Retained Heap
HPROF heap dump is a snapshot of a Java heap at a particular instance in time. The garbage collector is triggered before the dump is written. It contains information about all objects, all classes, GCR, and all information about the remaining objects. Heap does not contain allocation information. Shallow heap is the memory consumed by one object at that instance. Retained Heap is the sum of the shallow sizes of all objects in the retained set.

Leak Suspect Report with a Single Click
Acquire heap dumps

Heap dump can be obtained either by on-demand or by an out of memory error. In the Sun JVM 1.4.2_12 or after, we can get a heap dump on out-of-memory by using the following JVM parameter

-XX:+HeapDumpOnOutOfMemoryError

An on-demand heap dump can be obtained using the following JVM parameter:

-XX:+HeapDumpOnCtrlBreak

We can also get the heap dump using jmap, jconsole, and hprof.

Importing an hprof file
Open the downloaded hprof file into your workspace. Click on File -> Open Heap Dump and give the hprof file reference.

Once a file is opened, MAT process the hprof file. Check your heap restraints while processing huge hprof files. You can extend the heap configurations at MemoryAnalyzer.ini. Once parsing completes, we need to select a leak suspect report to check heap dump for leak suspects. It provides details about the different objects and why they have not been garbage collected.

We get a higher level of leak suspect report with a pie chart and list of leak suspects.

To get the top consumer at that particular instance, we need to click on Top Consumer in the Leak Identification Category.

The denominator tree lists the biggest objects. It's also called as a keep-alive tree as the next level shows those objects that are immediately prevented from garbage collections.

By drilling down, we can check incoming - outgoing references, GCR. The dominator tree can also be grouped by class loaders. The histogram view lists the objects grouped by class.

This view helps to identify the starting point for our analysis. Asample histogram view is illustrated below.

OQL Editor
MAT allows you to query the heap dump using SQL-like queries. OQL represent classes as tables, objects as rows, and fields as columns.

SELECT *
FROM [ INSTANCEOF ] <class name="name">
[ WHERE <filter-expression> ]
</filter-expression></class>

Conclusion
The Eclipse Memory analyzer provides a good offline analysis of a snapshot. I prefer to use both offline and online profilers to make sure my application is leak-proof.

Reference

About Pavan Gorakavi
Pavan Kumar Gorakavi is currently working as senior software developer in Dallas, TX. He is also acting as vice president for IPMA - Young Crew, USA.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1



ADS BY GOOGLE
Subscribe to the World's Most Powerful Newsletters

ADS BY GOOGLE

In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, disc...
In this presentation, you will learn first hand what works and what doesn't while architecting and d...
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22n...
In his session at 20th Cloud Expo, Scott Davis, CTO of Embotics, discussed how automation can provid...
Everyone wants the rainbow - reduced IT costs, scalability, continuity, flexibility, manageability, ...
Founded in 2000, Chetu Inc. is a global provider of customized software development solutions and IT...
SYS-CON Events announced today that DatacenterDynamics has been named “Media Sponsor” of SYS-CON's 1...
The standardization of container runtimes and images has sparked the creation of an almost overwhelm...
Most DevOps journeys involve several phases of maturity. Research shows that the inflection point wh...
Dynatrace is an application performance management software company with products for the informatio...
Today, we have more data to manage than ever. We also have better algorithms that help us access our...
Andi Mann, Chief Technology Advocate at Splunk, is an accomplished digital business executive with e...
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: D...
DevOpsSummit New York 2018, colocated with CloudEXPO | DXWorldEXPO New York 2018 will be held Novemb...
DXWorldEXPO LLC announced today that ICOHOLDER named "Media Sponsor" of Miami Blockchain Event by Fi...
@DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22...
SYS-CON Events announced today that IoT Global Network has been named “Media Sponsor” of SYS-CON's @...
To Really Work for Enterprises, MultiCloud Adoption Requires Far Better and Inclusive Cloud Monitori...
The best way to leverage your Cloud Expo presence as a sponsor and exhibitor is to plan your news an...
CloudEXPO New York 2018, colocated with DXWorldEXPO New York 2018 will be held November 11-13, 2018,...