RobAu RobAu - 1 year ago 578
Java Question

Java Heap Dump error - Metadata does not appear to be polymorphic

I get this Stacktrace when trying to take a heap dump from a running Java process. What causes this and what do I have to do to make a proper heap dump?

Dumping heap to dump.bin ...
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
Caused by: java.lang.InternalError: Metadata does not appear to be polymorphic
at sun.jvm.hotspot.types.basic.BasicTypeDataBase.findDynamicTypeForAddress(
at sun.jvm.hotspot.runtime.VirtualBaseConstructor.instantiateWrapperFor(
at sun.jvm.hotspot.oops.Metadata.instantiateWrapperFor(
at sun.jvm.hotspot.memory.DictionaryEntry.klass(
at sun.jvm.hotspot.memory.Dictionary.classesDo(
at sun.jvm.hotspot.memory.SystemDictionary.classesDo(
at sun.jvm.hotspot.memory.SystemDictionary.allClassesDo(
at sun.jvm.hotspot.utilities.HeapHprofBinWriter.writeClasses(
at sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(
... 6 more

Environment: CentOS 64 bit, Java OpenJDK Runtime Environment (build 1.8.0_31-b13) OpenJDK 64-Bit Server VM (build 25.31-b07, mixed mode)

to see the java version that is used:


My first try was:

/usr/lib/jvm/java-1.8.0-openjdk- -dump:format=b,file=dump.bin 14984

That got me :

14984: 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

So I ran with the

/usr/lib/jvm/java-1.8.0-openjdk- -F -dump:format=b,file=dump.bin 14984

Answer Source

Ok, I found it.

I was running the jmap command as root, but I had to run as the user that started the java process.

In my case:

sudo -u robau ./jmap -dump:format=b,file=/tmp/dump.bin 14984

Seems to be related to this JDK bug: