Heap wants some space!

So recently I wanted to perform a memory analysis on a heap dump of whooping 5GB using Eclipse’s Memory Analyzer Tool (MAT).

My Eclipse IDE fainted just by the idea of opening up and parsing this gigantic dump file.

One of the option here is to increase the max heap space of my Eclipse in .ini config file.

But if you are operating in a restricted mode, you won’t have authorization to modify files in C:\Program_Files

So in order to forcefully set the initialization arguments for JVM in eclipse,

open CMD add the path to eclipse’s executable file followed by vm arguments

C:/program_files/eclipse/eclipse.exe --vmargs --Xms2048m --Xmx14000m
  • vmargs: stating that following arguments are to be considered as arguments for virtual machine

  • Xms : initial heap space

  • Xmx: max heap space

  • 2048m is 2GB

  • 14000m is approx 14GB

So here I am manually setting the max heap size as 14GB so the heap dump can be parsed and analyzed by MAT which would require more headspace than the heap’s original size.

Although MAT in itself is very optimized and efficient tool sometimes it does end up needing quite some space for the analysis and 14 GB might have been an overkill but I didn't have time to wait for 88% completion of parsing just to see Eclipse: out of heap space error

This is possible as the user might not have the write access to a file but does have execution access.

Another way might have been to break the heap dump into several smaller parts and analyze them one by one. But I didn’t find any good references for that.

Also I meant to include complete breakdown of how to use MAT but found this explanation by Isuru Perera which covered MAT analysis very nicely.

P.S. Always make sure you clear all strong references, backward references, hidden/indirect references to objects which are supposed to be eligible for Garbage Collection.

20
Subscribe to my newsletter

Read articles from Siddhant Vispute directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Siddhant Vispute
Siddhant Vispute