jmap throws exception on java 1.4.2_12

I've been trying out the backported jmap and heap dump functionality on java 1.4.2_12 but I've run into a problem. Whenever I run jmap I get output similar to this:

alpine: /> /usr/j2se/bin/jmap -histo 1369

Attaching to process ID 1369, please wait...

Debugger attached successfully.

Server compiler detected.

JVM version is 1.4.2_12-b03

Iterating over heap. This may take a while...

Exception in thread "main" sun.jvm.hotspot.types.WrongTypeException: No suitable match for type of address 0x00168e80

at sun.jvm.hotspot.runtime.VirtualConstructor.instantiateWrapperFor(VirtualConstructor.java:62)

at sun.jvm.hotspot.memory.GenerationFactory.newObject(GenerationFactory.java:41)

at sun.jvm.hotspot.memory.GenCollectedHeap.getGen(GenCollectedHeap.java:63)

at sun.jvm.hotspot.oops.ObjectHeap.collectLiveRegions(ObjectHeap.java:483)

at sun.jvm.hotspot.oops.ObjectHeap.iterate(ObjectHeap.java:223)

at sun.jvm.hotspot.tools.ObjectHistogram.run(ObjectHistogram.java:25)

at sun.jvm.hotspot.tools.JMap.run(JMap.java:85)

at sun.jvm.hotspot.tools.Tool.start(Tool.java:204)

at sun.jvm.hotspot.tools.JMap.main(JMap.java:126)

Am I doing something subtly wrong?

[1261 byte] By [ColPanica] at [2007-10-3 4:04:10]
# 1

Which GC are you using? concurrent mark sweep? or serial mark-sweep? I think not all GC are supported in 1.4.2 backport of jmap. But, there is another way to get heapdump from a 1.4.2 VM. Please follow this link:

http://blogs.sun.com/alanb/entry/heapdumponoutofmemoryerror_option_in_5_0u7

This JVM built-in heap dumper supports all GC algorithms.

sundararajan.aa at 2007-7-14 22:03:19 > top of Java-index,Core,Monitoring & Management...
# 2

We are using concurrent mark sweep so that probably explains why it's not working. I have the HeapDumpOnOutOfMemory option set, but unfortunately it takes too long for an out of memory exception to occur.

I will try changing the GC parameters and see if I can get a heap dump that way.

Thanks for the quick response

c0lpanica at 2007-7-14 22:03:19 > top of Java-index,Core,Monitoring & Management...
# 3

I could get a heap dump by chaging the GC parameters, but when I tried to analyse the dump using jhat (from jdk 6) I get an exception:

# jhat heap.bin

Reading from heap.bin...

Dump file created Mon Sep 04 12:22:19 CEST 2006

Snapshot read, resolving...

Resolving 2345723 objects...

Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to com.sun.tools.hat.internal.model.JavaClass

at com.sun.tools.hat.internal.model.JavaObjectArray.resolve(JavaObjectArray.java:68)

at com.sun.tools.hat.internal.model.Snapshot.resolve(Snapshot.java:237)

at com.sun.tools.hat.Main.main(Main.java:152)

Isn't it supposed to work with a dump from a 1.4.2_12 jmap?

c0lpanica at 2007-7-14 22:03:19 > top of Java-index,Core,Monitoring & Management...