Skip to content

Instantly share code, notes, and snippets.

@mrbuk
Created May 20, 2015 08:52
Show Gist options
  • Save mrbuk/5726c469234238a26327 to your computer and use it in GitHub Desktop.
Save mrbuk/5726c469234238a26327 to your computer and use it in GitHub Desktop.
MAT headless mode
#!/bin/sh
#
# This script parses a heap dump.
#
# Usage: ParseHeapDump.sh <path/to/dump.hprof> [report]*
#
# The leak report has the id org.eclipse.mat.api:suspects
# The top component report has the id org.eclipse.mat.api:top_components
#
./MemoryAnalyzer -consolelog -application org.eclipse.mat.api.parse "$@"
#!/bin/bash
#
# run with './suspect_report.sh path_to_heapdump'
#
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 &
@mrbuk
Copy link
Author

mrbuk commented May 20, 2015

Prerequisites

Note: The ParseHeapDump.sh script should be part of your MAT distribution. So to run a suspect report the second script and the MAT distribution is needed.

Run

First see if the heap size defined in the suspect_report.sh is right for your case. If so execute ./suspect_report.sh heap_dump

As a result an archive with the report in form of HTML files will be created. (Resulting files are usually located in the MAT directory if you have executed the application from that location).

Note: This will only create the suspects, overview and top components report. If you want other stuff or only one report (e.g. suspect) replace the report id from the suspect_report.sh script with only the desired report and execute directly from command line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment