在Centos 64位和openjdk 7上的堆转储错误。

时间:2022-09-04 21:06:30

I'm trying to generate a heap dump on my machine that is running a glassfish 3.1.2 using a open-jdk7 java.

我正在试图在我的机器上生成一个堆转储,它使用一个开放的jdk7 java运行一个glassfish 3.1.2。

I'm using the following command :

我使用以下命令:

jmap -dump:live,format=b,file=dump.t -F 24935

But I keep getting this error :

但我一直犯这个错误:

Attaching to process ID 24935, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 23.7-b01
Dumping heap to dump.t ...
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at sun.tools.jmap.JMap.runTool(JMap.java:197)
        at sun.tools.jmap.JMap.main(JMap.java:128)
Caused by: sun.jvm.hotspot.utilities.AssertionFailure: Expecting GenCollectedHeap, G1CollectedHeap, or ParallelScavengeHeap, but got sun.jvm.hotspot.gc_interface.CollectedHeap
        at sun.jvm.hotspot.utilities.Assert.that(Assert.java:32)
        at sun.jvm.hotspot.oops.ObjectHeap.collectLiveRegions(ObjectHeap.java:605)
        at sun.jvm.hotspot.oops.ObjectHeap.iterate(ObjectHeap.java:244)
        at sun.jvm.hotspot.utilities.AbstractHeapGraphWriter.write(AbstractHeapGraphWriter.java:51)
        at sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(HeapHprofBinWriter.java:416)
        at sun.jvm.hotspot.tools.HeapDumper.run(HeapDumper.java:56)
        at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
        at sun.jvm.hotspot.tools.HeapDumper.main(HeapDumper.java:77)
        ... 6 more

Here is my full java version :

这是我的完整java版本:

[ufasoli]$ java -version
java version "1.7.0_19"
OpenJDK Runtime Environment (rhel-2.3.9.1.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

The exact CentOS version is :

CentOS的准确版本是:

CentOS release 6.3 (Final)

Any ideas?

什么好主意吗?

5 个解决方案

#1


13  

Posting this so I dont keep forgetting the solution myself :P

这样我就不会一直忘记解决方案了:P。

This works:

如此:

$ sudo /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51.x86_64/bin/jmap -dump:format=b,file=./testDump   8894
Dumping heap to /home/<snip>/testDump ...
Heap dump file created

This fails:

这个操作失败:

$ sudo /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51.x86_64/bin/jmap -heap:format=b     8894
Attaching to process ID 8894, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.45-b08
Dumping heap to heap.bin ...
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at     sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.tools.jmap.JMap.runTool(JMap.java:197)
at sun.tools.jmap.JMap.main(JMap.java:128)
Caused by: sun.jvm.hotspot.utilities.AssertionFailure: Expecting GenCollectedHeap, G1CollectedHeap, or ParallelScavengeHeap, but got sun.jvm.hotspot.gc_interface.CollectedHeap
at sun.jvm.hotspot.utilities.Assert.that(Assert.java:32)
at sun.jvm.hotspot.oops.ObjectHeap.collectLiveRegions(ObjectHeap.java:604)
at sun.jvm.hotspot.oops.ObjectHeap.iterate(ObjectHeap.java:244)
at sun.jvm.hotspot.utilities.AbstractHeapGraphWriter.write(AbstractHeapGraphWriter.java:51)
at sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(HeapHprofBinWriter.java:416)
at sun.jvm.hotspot.tools.HeapDumper.run(HeapDumper.java:56)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
at sun.jvm.hotspot.tools.HeapDumper.main(HeapDumper.java:77)
... 6 more

#2


4  

This may be related, but on some Java versions, there seems to be a slight oddity on recent RHEL / Centos (version >= 6) whereby jmap, jstack and friends need to be run as the exact user that started the process - and it will not work if run as root.

这可能是相关的,但在一些Java版本中,似乎有一种轻微的奇怪最近RHEL / Centos(版本> = 6)jmap,jstack和朋友需要运行的用户开始的过程,它不会工作,如果作为根用户运行。

A command like:

一个命令:

sudo -H -u <USERNAME WHO STARTED PROCESS> jmap -histo <PID>

should take care of it, assuming you have appropriate sudo privileges.

如果你有合适的sudo特权,应该好好考虑一下。

#3


2  

Try running without the -F option

尝试运行没有-F选项。

#4


1  

According to http://iamadevops.tumblr.com/post/109281462774/howto-fix-jmap-f-dump-format-b-on-archlinux the solution is to "recompile your java with the debug symbols not stripped out" yikes.

根据http://iamadevops.com/post/109281462774 /howto-fix-jmap-f-dump-format-b-on-archlinux,解决方案是“用调试符号重新编译您的java,而不是去掉”yike。

#5


0  

If you don't have the option to recompile the code with debug symbols and you have JMX configured, then you may try to generate a heapdump with VisualVM.

如果您没有使用调试符号重新编译代码的选项,并且您已经配置了JMX,那么您可以尝试使用VisualVM生成一个heapdump。

For this, start VisualVM and connect to the host via JMX. On the topleft of the monitor panel, you'll see a "Head Dump" button.

为此,启动VisualVM并通过JMX连接到主机。在监视器面板的左上方,您将看到一个“Head Dump”按钮。

The format is the dump file will be different, but you'll be able to open it with jhat or VisualVM.

格式是转储文件将是不同的,但是您可以使用jhat或VisualVM打开它。

#1


13  

Posting this so I dont keep forgetting the solution myself :P

这样我就不会一直忘记解决方案了:P。

This works:

如此:

$ sudo /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51.x86_64/bin/jmap -dump:format=b,file=./testDump   8894
Dumping heap to /home/<snip>/testDump ...
Heap dump file created

This fails:

这个操作失败:

$ sudo /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51.x86_64/bin/jmap -heap:format=b     8894
Attaching to process ID 8894, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.45-b08
Dumping heap to heap.bin ...
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at     sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.tools.jmap.JMap.runTool(JMap.java:197)
at sun.tools.jmap.JMap.main(JMap.java:128)
Caused by: sun.jvm.hotspot.utilities.AssertionFailure: Expecting GenCollectedHeap, G1CollectedHeap, or ParallelScavengeHeap, but got sun.jvm.hotspot.gc_interface.CollectedHeap
at sun.jvm.hotspot.utilities.Assert.that(Assert.java:32)
at sun.jvm.hotspot.oops.ObjectHeap.collectLiveRegions(ObjectHeap.java:604)
at sun.jvm.hotspot.oops.ObjectHeap.iterate(ObjectHeap.java:244)
at sun.jvm.hotspot.utilities.AbstractHeapGraphWriter.write(AbstractHeapGraphWriter.java:51)
at sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(HeapHprofBinWriter.java:416)
at sun.jvm.hotspot.tools.HeapDumper.run(HeapDumper.java:56)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
at sun.jvm.hotspot.tools.HeapDumper.main(HeapDumper.java:77)
... 6 more

#2


4  

This may be related, but on some Java versions, there seems to be a slight oddity on recent RHEL / Centos (version >= 6) whereby jmap, jstack and friends need to be run as the exact user that started the process - and it will not work if run as root.

这可能是相关的,但在一些Java版本中,似乎有一种轻微的奇怪最近RHEL / Centos(版本> = 6)jmap,jstack和朋友需要运行的用户开始的过程,它不会工作,如果作为根用户运行。

A command like:

一个命令:

sudo -H -u <USERNAME WHO STARTED PROCESS> jmap -histo <PID>

should take care of it, assuming you have appropriate sudo privileges.

如果你有合适的sudo特权,应该好好考虑一下。

#3


2  

Try running without the -F option

尝试运行没有-F选项。

#4


1  

According to http://iamadevops.tumblr.com/post/109281462774/howto-fix-jmap-f-dump-format-b-on-archlinux the solution is to "recompile your java with the debug symbols not stripped out" yikes.

根据http://iamadevops.com/post/109281462774 /howto-fix-jmap-f-dump-format-b-on-archlinux,解决方案是“用调试符号重新编译您的java,而不是去掉”yike。

#5


0  

If you don't have the option to recompile the code with debug symbols and you have JMX configured, then you may try to generate a heapdump with VisualVM.

如果您没有使用调试符号重新编译代码的选项,并且您已经配置了JMX,那么您可以尝试使用VisualVM生成一个heapdump。

For this, start VisualVM and connect to the host via JMX. On the topleft of the monitor panel, you'll see a "Head Dump" button.

为此,启动VisualVM并通过JMX连接到主机。在监视器面板的左上方,您将看到一个“Head Dump”按钮。

The format is the dump file will be different, but you'll be able to open it with jhat or VisualVM.

格式是转储文件将是不同的,但是您可以使用jhat或VisualVM打开它。