Analyzing large Java heap dumps using Memory Analyzer CLI in Linux
Description:
When you have a situation or need to analyze a really large heap dump (like 30/40 GB), then most of the time MAT UI will fail to analyze such large files, in that case, you can use Memory Analyzer CLI in Linux/Windows. In this post, we will see how we use the analyzer tool in Linux
Pre-req to setup
- Make sure you have enough physical/virtual (VM) memory available. (~at least equal to the size of the file to make memory analyzer run smooth).
- Make Sure you have the tool downloaded from here http://www.eclipse.org/mat/downloads.php
- Make sure you have the necessary privileges or access to the Linux system.
Steps to Follow
- unzip download memory analyzer tool using unzip command
- unzip MemoryAnalyzer-1.7.0.20170613-linux.gtk.x86_64.zip
- mat folder will be created then run “cd mat”
- Run command to start to dump analyzer
- ./ParseHeapDump.sh /dumps/heap.date.bin ls -vmargs -Xmx40g -XX:-UseGCOverheadLimit
- Xmx40g – Here 40g represents allocated memory in GB for this process alters this as required.
- /dumps/heap.date.bin – This file represents your dump file alter the filename with full path in it as required.
- ./ParseHeapDump.sh /dumps/heap.date.bin ls -vmargs -Xmx40g -XX:-UseGCOverheadLimit
- Above command will take time based on the size of the dump file and it will generate index files on the directory where your dump file exists
- Now to generate html files run below command
- ./ParseHeapDump.sh /dumps/heap.date.bin org.eclipse.mat.api:suspects
- org.eclipse.mat.api:suspects – represents report type
- Below are the other report types available
- ./ParseHeapDump.sh /dumps/heap.date.bin org.eclipse.mat.api:suspects
org.eclipse.mat.api:suspects
org.eclipse.mat.api:overview
org.eclipse.mat.api:top_
- The above command will generate the jvm_suspects.zip file which consists of html files.
- Now, these Html reports can be shared with anybody by SCP/email/FTP as required.