如何通过命令行读取Java堆转储(无GUI)

时间:2014-05-25 17:47:07

标签: java heap-dump

我已经加入了一台机器并正在运行一个java程序。退出一段时间后,我得到一个堆转储,并将其发送到一个文件java_pid28356.hprof如何使用命令行工具从该文件中读取以查找导致转储的原因?

1 个答案:

答案 0 :(得分:1)

less %DUMP_FILE_DIR%/java_pid28356.hprof

你也可以尝试ParseHeapDump.sh - eclipse内存分析器的一部分(你可以google它,但为了方便我发布下面的脚本)

#!/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 "$@"