With Oracle's Hotspot JVM, it looks like jmap -dump:file=/tmp/dump.txt <pid>
can be used to take a heap dump.
However, Eclipse OpenJ9 doesn't include the jmap
tool - and if you try to use the regular jmap
with OpenJ9's jvm, it gives the exception:
Exception in thread "main" java.lang.ClassCastException: com.ibm.tools.attach.attacher.OpenJ9VirtualMachine incompatible with sun.tools.attach.HotSpotVirtualMachine
at java.lang.ClassCastException.<init>(java.base@10.0.2-adoptopenjdk/ClassCastException.java:71)
at sun.tools.jmap.JMap.executeCommandForPid(jdk.jcmd@10.0.2-adoptopenjdk/JMap.java:128)
at sun.tools.jmap.JMap.dump(jdk.jcmd@10.0.2-adoptopenjdk/JMap.java:192)
at sun.tools.jmap.JMap.main(jdk.jcmd@10.0.2-adoptopenjdk/JMap.java:110)
So, how can one take a heap dump with OpenJ9?