PDA

View Full Version : Jmap Heap Dumps and JDK versions


rjshuttleworth
24-09-2010, 07:53
Anyone experienced an issue attaching to a VM to do a heap dump? I am getting an incorrect version reported. Here's a jmap output:

[root@domU-12-31-39-0E-AE-12 ~]# jmap 27624
Attaching to process ID 27624, please wait...
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at sun.tools.jmap.JMap.runTool(JMap.java:196)
at sun.tools.jmap.JMap.main(JMap.java:128)
Caused by: sun.jvm.hotspot.runtime.VMVersionMismatchException : Supported versions are 1.6.0-b09. Target VM is 10.0-b19
at sun.jvm.hotspot.runtime.VM.checkVMVersion(VM.java: 217)
at sun.jvm.hotspot.runtime.VM.<init>(VM.java:280)
at sun.jvm.hotspot.runtime.VM.initialize(VM.java:333)
at sun.jvm.hotspot.bugspot.BugSpotAgent.setupVM(BugSp otAgent.java:594)
at sun.jvm.hotspot.bugspot.BugSpotAgent.go(BugSpotAge nt.java:494)
at sun.jvm.hotspot.bugspot.BugSpotAgent.attach(BugSpo tAgent.java:332)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:163)
at sun.jvm.hotspot.tools.HeapSummary.main(HeapSummary .java:39)
... 6 more

and here's my java version:

[root@domU-12-31-39-0E-AE-12 ~]# java -version
java version "1.6.0_04"
Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
Java HotSpot(TM) 64-Bit Server VM (build 10.0-b19, mixed mode)
[root@domU-12-31-39-0E-AE-12 ~]#

Seems to me that running in server mode reports back to jmap the wrong version number.

I am running jmap from the bin directory of the VM that is running my service (tcserver) and it's definitely java 1.6!

Any ideas?

Ryan

Barry
13-12-2010, 11:26
Hi Ryan,

Sorry for the late reply. I've had this issue before, Jmap and other JVM utilities are extremely version sensitive.
Have you tried executing the command as: ./jmap <pid> (from the bin folder of the running JVM)

By not including the ./ the system will still default to the $PATH and $CLASSPATH and not the current folder, which could be the other JVM install.

Your best bet is to only have one install, but that's not always possible

ashishkanchan
31-01-2013, 10:15
Anyone experienced an issue attaching to a VM to do a heap dump? I am getting an incorrect version reported. Here's a jmap output:

jmap -dump:format=b,file=/var/neoMemDump/dump.bin 12550
12550: Unable to open socket file: target process not responding or HotSpot VM not loaded
The -F option can be used when the target process is not responding
[root@MyTimes237 bin]# jmap -F -dump:format=b,file=/var/neoMemDump/dump.bin 12550
Attaching to process ID 12550, please wait...
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at sun.tools.jmap.JMap.runTool(JMap.java:196)
at sun.tools.jmap.JMap.main(JMap.java:128)
Caused by: sun.jvm.hotspot.runtime.VMVersionMismatchException : Supported versions are 14.0-b16. Target VM is 20.5-b03
at sun.jvm.hotspot.runtime.VM.checkVMVersion(VM.java: 223)
at sun.jvm.hotspot.runtime.VM.<init>(VM.java:286)
at sun.jvm.hotspot.runtime.VM.initialize(VM.java:344)
at sun.jvm.hotspot.bugspot.BugSpotAgent.setupVM(BugSp otAgent.java:594)
at sun.jvm.hotspot.bugspot.BugSpotAgent.go(BugSpotAge nt.java:494)
at sun.jvm.hotspot.bugspot.BugSpotAgent.attach(BugSpo tAgent.java:332)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:163)
at sun.jvm.hotspot.tools.HeapDumper.main(HeapDumper.j ava:77)
... 6 more



My Java Version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)


please anyone let me know, how can i take heap dump

kjkoster
31-01-2013, 10:49
Dear ashishkanchan,

You need to use the jmap that comes with the JVM. From your error message I gather that you are using a different version of jmap than of the JVM.

Please check what JVMs are installed on your machine and ensure than when you run jmap, you use the right version.

To solve such issues I never rely on path. Instead I set JAVA_HOME to be the one that the JVM uses and then invoke both the JVM and jmap like so:


$ JAVA_HOME=/usr/local/jdk1.6.0
$ export JAVA_HOME
$ ${JAVA_HOME}/bin/java ...

...

$ $(JAVA_HOME}/bin/jmap ...


Hope this helps.

Kees Jan

ashishkanchan
31-01-2013, 11:12
Thanks Boss