繁体   English   中英

如何从核心转储文件中提取JVM堆转储?

[英]How to extract JVM heap dump from core dump file?

我正在尝试将 Java 进程的 Linux 核心转储转换为适合使用 Eclipse MAT 进行分析的堆转储文件。 根据这篇博文,适应了较新的 OpenJDK 12,我创建了一个核心转储,然后运行jhsdb jmap将转储转换为 HPROF 格式:

>sudo gcore -o dump 24934
[New LWP 24971]
...
[New LWP 17921]
warning: Could not load shared library symbols for /tmp/jffi4106753050390578111.so.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f94c7e9e98d in pthread_join (threadid=140276994615040, thread_return=0x7ffc716d47a8) at pthread_join.c:90
90      pthread_join.c: No such file or directory.
warning: target file /proc/24934/cmdline contained unexpected null characters
warning: Memory read failed for corefile section, 1048576 bytes at 0x7f93756a6000.
warning: Memory read failed for corefile section, 1048576 bytes at 0x7f9379bec000.
...
warning: Memory read failed for corefile section, 1048576 bytes at 0x7f94c82dd000.
Saved corefile dump.24934

> ls -sh dump.24934 
22G dump.24934

> /usr/lib/jvm/zulu-12-amd64/bin/jhsdb jmap --exe /usr/lib/jvm/zulu-12-amd64/bin/java --core dump.24934 --binaryheap --dumpfile jmap-dump.24934
Attaching to core dump.24934 from executable /usr/lib/jvm/zulu-12-amd64/bin/java, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 12.0.1+12
null

> ls -sh jmap-dump.24934 
3.3M jmap-dump.24934

核心转储文件是 22 Gb,而堆转储文件只有 3 Mb,因此jhsdb jmap命令可能无法处理整个核心转储。 此外,Eclipse MAT 无法打开堆转储文件并显示以下消息: The HPROF parser encountered a violation of the HPROF specification that it could not safely handle. This could be due to file truncation or a bug in the JVM. The HPROF parser encountered a violation of the HPROF specification that it could not safely handle. This could be due to file truncation or a bug in the JVM.

亚历克斯,

这有两种可能性。

首先,gcore 是 gdb 的方便脚本。 我看到它提示一些警告消息,说加载 solib 有困难。 gdb 可能首先会生成一个损坏的核心文件。 您可以尝试使用 gdb 加载核心文件,看看它是否可以解析它。

其次,jhsdb自己解析core文件。 您可以使用环境变量 LIBSAPROC_DEBUG=1 来获取其跟踪。 它将帮助您了解解析中的错误。

为什么不直接使用 jmap -dump dump java heap? 这将跳过核心转储文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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