Eclipse MAT – Titbits

Eclipse MAT is a great JVM Memory Analysis tool. Here are few tid-bits to use it effectively.


Fig: Eclipse MAT

1. Use stand-alone version

Two versions of Eclipse MAT is available:

1. Stand-alone

2. Eclipse Plugin

Based on my personnel 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 than 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 you will add -Xmx3g at the bottom.



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 displays 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 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 doesn’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

Fig: Eclipse MAT 1.4.0, showing how to enable ‘Keep unreachable objects’

4. Smart Data Settings

Eclipse MAT by default displays data in bytes. It’s difficult to read large object sizes in bytes and digest it. Example Eclipse MAT prints object size like this: “193,006,368”. It’s much easier if this data can be displayed in KB, MB, GB i.e. “184.07 MB”.

Fig: Eclipse MAT default option showing object size in bytes

Eclipse MAT provides an option to display object size in KB, MB, GB based on their appropriate size. It can be enabled by following below steps:

  1. Go to Window > Preferences …
  2. Click on ‘Memory Analyzer’
  3. In the ‘Bytes Display’ section select ‘Smart: If the value is a gigabyte or …’
  4. Click on ‘OK’ button
Fig: Settings to enable ‘smart’ data display

Once this setting change is made, all data will appear in much more readable KB, MB, GB format, as shown in below figure.

Fig: Eclipse MAT displaying of object size in KB, MB, GB after enabling ‘smart’ settings.

One thought on “Eclipse MAT – Titbits

Add yours

Leave a Reply

Powered by

Up ↑

%d bloggers like this: