0

I worked mainly with the IBM SDK so there is a specific JVM argument you can use in order to enable dumps (heap, thread, system core) on specific events or exceptions (java.lang.OutOfMemoryError, SIGTERM, etc...)

I want to be able to do the same thing using the Oracle JDK. I only see the argument: -XX:+HeapDumpOnOutOfMemoryError which will only generate a heap dump for the specific exception java.lang.OutOfMemoryError.

Basically I do not have access to the code, so I want to be able to have the JVM generate both a heap dump and a Java thread dump for analysis (java.lang.OutOfMemoryError is one of many other events).

Jon Heller
  • 34,999
  • 6
  • 74
  • 132
wFateem
  • 346
  • 1
  • 2
  • 11

1 Answers1

3

JVM Tool Interface is a standard way to implement such tools.

JVMTI Agents can set up callbacks for a variety of events.

Here are some examples how to handle exceptions events and how to dump heap before VM exit.

Community
  • 1
  • 1
apangin
  • 92,924
  • 10
  • 193
  • 247
  • I did extensive research and it seems like the method you mentioned is actually the only way to achieve this on an Oracle JVM. It was kind of disappointing for me to find that out because achieving the same thing using an IBM JVM is much simpler where you simply add a parameter and modifying it depending on the event and type of dump you need (Java, heap or system core). I haven't coded in C/C++ in ages, this is going to be a daunting task :) – wFateem Jan 27 '17 at 20:52