Wednesday, February 28, 2018

Eclipse MAT



https://gist.github.com/mrbuk/5726c469234238a26327
nohup ./ParseHeapDump.sh $1 org.eclipse.mat.api:suspects org.eclipse.mat.api:overview org.eclipse.mat.api:top_components -vmargs -Xmx96g -XX:-UseGCOverheadLimit > mat_report.out &
java -Xms8g -Xmx12g -jar  mat.app/Contents/Eclipse/plugins/org.eclipse.equinox.launcher_1*.jar -application org.eclipse.mat.api.parse java_pid2992.hprof org.eclipse.mat.api:suspects org.eclipse.mat.api:overview org.eclipse.mat.api:top_components

http://javaforu.blogspot.com/2013/11/analyzing-large-java-heap-dumps-when.html
https://www.jeroenreijn.com/2010/10/large-heap-dump-analysis-with-eclipse.html
https://wiki.eclipse.org/MemoryAnalyzer/FAQ
java -Xmx6g -jar plugins/org.eclipse.equinox.launcher_1*.jar -consoleLog -application org.eclipse.mat.api.parse path/to/dump.dmp.zip org.eclipse.mat.api:suspects org.eclipse.mat.api:overview org.eclipse.mat.api:top_components

You need to copy all files which are present in that directory to your laptop. I've done this successfully many times. I run the analyser on the server using
The org.eclipse.mat.api:suspects argument creates a ZIP file containing the leak suspect report. This argument is optional.
The org.eclipse.mat.api:overview argument creates a ZIP file containing the overview report. This argument is optional.
The org.eclipse.mat.api:top_components argument creates a ZIP file containing the top components report. This argument is optional.

http://javaforu.blogspot.com/2013/11/analyzing-large-java-heap-dumps-when.html
https://stackoverflow.com/questions/2382024/how-to-use-existing-eclipse-mat-indexes-for-interactive-analysis
You need to copy all files which are present in that directory to your laptop. I've done this successfully many times. I run the analyser on the server using

/opt/mat/MemoryAnalyzer -consolelog -application org.eclipse.mat.api.parse "$@" org.eclipse.mat.api:suspects org.eclipse.mat.api:top_components


https://stackoverflow.com/questions/7254017/tool-for-analyzing-large-java-heap-dumps
Normally, what I use is ParseHeapDump.sh included within Eclipse Memory Analyzer and described here, and I do that onto one our more beefed up servers (download and copy over the linux .zip distro, unzip there). The shell script needs less resources than parsing the heap from the GUI, plus you can run it on your beefy server with more resources (you can allocate more resources by adding something like -vmargs -Xmx40g -XX:-UseGCOverheadLimit to the end of the last line of the script. For instance, the last line of that file might look like this after modification
./MemoryAnalyzer -consolelog -application org.eclipse.mat.api.parse "$@" -vmargs -Xmx40g -XX:-UseGCOverheadLimit
Run it like ./path/to/ParseHeapDump.sh ../today_heap_dump/jvm.hprof
After that succeeds, it creates a number of "index" files next to the .hprof file.
After creating the indices, I try to generate reports from that and scp those reports to my local machines and try to see if I can find the culprit just by that (not just the reports, not the indices). Here's a tutorial on creating the reports.
Example report:
./ParseHeapDump.sh ../today_heap_dump/jvm.hprof org.eclipse.mat.api:suspects
Other report options:
org.eclipse.mat.api:overview and org.eclipse.mat.api:top_components
If those reports are not enough and if I need some more digging (i.e. let's say via oql), I scp the indices as well as hprof file to my local machine, and then open the heap dump (with the indices in the same directory as the heap dump) with my Eclipse MAT GUI. From there, it does not need too much memory to run.
EDIT: I just liked to add two notes :
  • As far as I know, only the generation of the indices is the memory intensive part of Eclipse MAT. After you have the indices, most of your processing from Eclipse MAT would not need that much memory.
  • Doing this on a shell script means I can do it on a headless server (and I normally do it on a headless server as well, because they're normally the most powerful ones). And if you have a server that can generate a heap dump of that size, chances are, you have another server out there that can process that much of a heap dump as well.
Important note: ParseHeapDump.sh is packaged with the Linux version only, not the OSX version -- eclipse.org/mat/downloads.php

Labels

Review (572) System Design (334) System Design - Review (198) Java (189) Coding (75) Interview-System Design (65) Interview (63) Book Notes (59) Coding - Review (59) to-do (45) Linux (43) Knowledge (39) Interview-Java (35) Knowledge - Review (32) Database (31) Design Patterns (31) Big Data (29) Product Architecture (28) MultiThread (27) Soft Skills (27) Concurrency (26) Cracking Code Interview (26) Miscs (25) Distributed (24) OOD Design (24) Google (23) Career (22) Interview - Review (21) Java - Code (21) Operating System (21) Interview Q&A (20) System Design - Practice (20) Tips (19) Algorithm (17) Company - Facebook (17) Security (17) How to Ace Interview (16) Brain Teaser (14) Linux - Shell (14) Redis (14) Testing (14) Tools (14) Code Quality (13) Search (13) Spark (13) Spring (13) Company - LinkedIn (12) How to (12) Interview-Database (12) Interview-Operating System (12) Solr (12) Architecture Principles (11) Resource (10) Amazon (9) Cache (9) Git (9) Interview - MultiThread (9) Scalability (9) Trouble Shooting (9) Web Dev (9) Architecture Model (8) Better Programmer (8) Cassandra (8) Company - Uber (8) Java67 (8) Math (8) OO Design principles (8) SOLID (8) Design (7) Interview Corner (7) JVM (7) Java Basics (7) Kafka (7) Mac (7) Machine Learning (7) NoSQL (7) C++ (6) Chrome (6) File System (6) Highscalability (6) How to Better (6) Network (6) Restful (6) CareerCup (5) Code Review (5) Hash (5) How to Interview (5) JDK Source Code (5) JavaScript (5) Leetcode (5) Must Known (5) Python (5)

Popular Posts