The Eclipse Memory Analyzer is a fast and feature-rich Java heap analyzer that helps you find memory leaks and reduce memory consumption.
Use the Memory Analyzer to analyze productive heap dumps with hundreds of millions of objects, quickly calculate the retained sizes of objects, see who is preventing the Garbage Collector from collecting objects, and run a report to automatically extract leak suspects.
Two related types of leaks are ClassLoader leaks and Thread leaks. When a Web Application starts a new thread, the WebappClassLoader becomes the Thread's ContextClassLoader. If the Thread never dies (e.g. TimerTask Threads, Schedulers, Cache Cleanup-Threads), the WebappClassLoader cannot be garbage collected and hence will suck up all the precious memory. Such a kind of leaks, easily we can find out with Memory Analyzer..
A Java heap dump is a snapshot of the complete Java object graph at a certain point in time. It is stored in a binary format called HPROF.
It includes all objects, fields, primitive types and object references.
The Eclipse MAT tooling is a set of plug-ins which visualize the references to objects based on Java heap dumps and provides tools to identify potential memory leaks.
It is possible to instruct the JVM to create automatically a heap dump in case that it runs out of memory, i.e. in case of a OutOfMemoryError error. To instruct the JVM to create a heap dump in such a situation, start your Java application with the -XX:+HeapDumpOnOutOfMemoryError option.