简体   繁体   中英

How to read a Java heap dump by command line (No GUI)

I've ssh'ed into a machine and am running a java program. After quit a while, I get a heap dump and have sent that into a file java_pid28356.hprof How can I read from that file with just command line tools to find what is causing the dump?

less %DUMP_FILE_DIR%/java_pid28356.hprof

Also you can try ParseHeapDump.sh - part of eclipse memory analyzer (you can google it, but I post the script below for your convenience)

#!/bin/sh
#
# This script parses a heap dump.
# Adjust the path to java, version 5 or later, and the heap size as required.
# Suitable for 64-bit and 32-bit Java, but a 64-bit Java is required
# for larger heap sizes.
#
# Usage: ParseHeapDump.sh <path/to/dump.dmp.zip> [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
#

java -Xmx3072M -jar "`dirname "$0"`"/plugins/org.eclipse.equinox.launcher_1*.jar -consoleLog -application org.eclipse.mat.api.parse "$@"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM