3 ms·
Well, it seems to me that XX:HeapDumpOnOutOfMemoryError is only useful if you run out of memory, not for other errors such as NPE. The other one XX:OnError I am
by js8 8y ago
Well, it seems to me that XX:HeapDumpOnOutOfMemoryError is only useful if you run out of memory, not for other errors such as NPE. The other one XX:OnError I am not really sure how to use with the JVM.. I mean can probably get the dump of the process on certain systems but I am not clear how to then proceed to get the actual dump of Java heap out of that. (And also, it's not clear what kind of cleanup happens inside JVM between the error and the execution of the command.)
- wtetzner 8y agoI believe you can do something like this: -XX:OnError="jcmd %p GC.heap_dump /heap-dumps/%p.dump" Then it will put a heap dump into `/heap-dumps/<pid>.dump`. https://www.baeldung.com/java-heap-dump-capture https://www.baeldung.com/java-heap-dump-capture