使用 JMAP 进行堆转储时的异常

2022-09-03 00:39:24

当我使用堆转储时,我得到以下异常

jmap -F -dump:format=b,file=/tmp/heapdump/before.hprof 10737

Attaching to process ID 10737, please wait...
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at sun.tools.jmap.JMap.runTool(JMap.java:179)
    at sun.tools.jmap.JMap.main(JMap.java:110)
Caused by: java.lang.RuntimeException: Type "nmethodBucket*", referenced in VMStructs::localHotSpotVMStructs in the remote VM, was not present in the remote VMStructs::localHotSpotVMTypes table (should have been caught in the debug build of that VM). Can not continue.
    at sun.jvm.hotspot.HotSpotTypeDataBase.lookupOrFail(HotSpotTypeDataBase.java:361)
    at sun.jvm.hotspot.HotSpotTypeDataBase.readVMStructs(HotSpotTypeDataBase.java:252)
    at sun.jvm.hotspot.HotSpotTypeDataBase.<init>(HotSpotTypeDataBase.java:87)
    at sun.jvm.hotspot.bugspot.BugSpotAgent.setupVM(BugSpotAgent.java:568)
    at sun.jvm.hotspot.bugspot.BugSpotAgent.go(BugSpotAgent.java:494)
    at sun.jvm.hotspot.bugspot.BugSpotAgent.attach(BugSpotAgent.java:332)
    at sun.jvm.hotspot.tools.Tool.start(Tool.java:163)
    at sun.jvm.hotspot.tools.HeapDumper.main(HeapDumper.java:77)

有人知道如何解决这个问题吗?


答案 1

我看到了相同的错误,因为我的jmap路径与java进程的路径不同(即针对两个不同的版本)。

运行带有我的JDK完整路径的jmap解决了这个问题。


答案 2

如果使用 OpenJDK,则需要安装 debuginfo-packages。

在 Centos 中,这适用于 - - 或sudo debuginfo-install java-1.8.0-openjdksudo yum install java-1.8.0-openjdk-debuginfo.x86_64

请参阅 - https://bugzilla.redhat.com/show_bug.cgi?id=1010786#c15 - Amazon Linux - install openjdk-debuginfo?