Eclipse MAT is a great JVM Memory Analysis tool. Here are few tidbits to use it effectively.
1. Use stand-alone version
Two versions of Eclipse MAT is available:
2. Eclipse Plugin
Based on my personal experience, stand-alone version seems to works better and faster then plugin version. So I would highly recommend installing Stand-alone version.
2. Eclipse MAT – heap size
If you are analyzing a heap dump of size, say 2 GB, allocate at least 1 GB additional space for Eclipse MAT. If you can allocate more heap space, then it’s more the merrier. You can allocate additional heap space for Eclipse MAT tool, by editing MemoryAnalyzer.ini file. This file is located in the same folder where MemoryAnalyzer.exe is present. To the MemoryAnalyzer.ini you will add -Xmx3g at the bottom.
-startup plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20140603-1326 -vmargs -Xmx3g
3. Enable ‘keep unreachable objects’
From it’s reporting Eclipse MAT removes the object which it thinks as ‘unreachable.’ As ‘unreachable’ objects are eligible for garbage collection, MAT doesn’t display them in the report. Eclipse MAT classifies Local variables in a method as ‘unreachable objects’. Once thread exits the method, objects in local variables will be eligible for garbage collection.
However, there are several cases where a thread will go into a ‘BLOCKED’ or prolonged ‘WAITING’, ‘TIMED_WAITING’ state. In such circumstances local variables will be still alive in memory, occupying space. Since Eclipse MAT default settings don’t show the unreachable objects, you will not get visibility into these objects. You can change the default settings in Eclipse MAT 1.4.0 version by:
1. Go to Window > Preferences …
2. Click on ‘Memory Analyzer’
3. Select ‘Keep unreachable objects’
4. Click on ‘OK’ button