Hi,
I'm experimenting with OpenJ9 as a replacement for the regular JDK.
One feature I love about the normal JDK is the function HotSpotDiagnosticMXBean.dumpHeap() which allows me to inspect the Java heap programmatically and look for memory leaks.
However, OpenJ9 does not provide this method.
Any plans to add this method - or any other way to get a heap dump?
Thank you in advance.
I think you can achieve the same by using OpenJ9DiagnosticsMXBean.triggerDump. There are other similar APIs in the class which you may find useful.
Relevant links: OpenJ9DiagnosticsMXBean javadoc
Blog post on OpenJ9DiagnosticsMXBean: https://blog.openj9.org/2018/06/27/gather-diagnostic-data-from-your-containerized-java-application-on-the-fly/
Great! I'll test if that works.
I do have a follow-up question... I made an OpenJ9 "heap" dump, but it's not compatible with VisualVM et al. Any way to bridge this gap? Many greetings
You can use https://www.eclipse.org/mat/, note you need to instal the IBM DTFJ plugin, which is a menu entry, see instructions here https://www.eclipse.org/openj9/docs/dump_heapdump/
Otherwise, you can try using the hprof agent to create the dump, as I'm guessing VisualVM reads the hprof format. https://docs.oracle.com/javase/8/docs/technotes/samples/hprof.html
OpenJ9 doesn't have built in support for the hprof format.
Otherwise, you can try using the hprof agent to create the dump
Hmm. Is there even a chance the hprof agent would work with OpenJ9? Isn't it made for Oracle JDKs?
Yes, VisualVM reads the hprof format.
I actually have two requirements: a visual heap dump analyzer, which I'm guessing Eclipse MAT will provide.
The other requirement is a programmatic library to analyze heap dumps. I'm currently using this tool for that. Is there anything similar for OpenJ9 heap dumps?
Thanks
The hprof agent is a standard JVMTI agent, and should work with any JVM that supports JVMTI, including OpenJ9. The OpenJ9 Java 8 build includes the hprof agent.
It was removed in versions after Java 8, although I expect the Java 8 copy will still work with later versions.
https://openjdk.java.net/jeps/240
The DTFJ API can be used to programmatically read OpenJ9 dumps. All the code is open source, but we haven't gotten to moving the docs outside of IBM yet.
https://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/com.ibm.java.vm.80.doc/docs/dtfj.html
Thanks, you guys are very helpful.