4 ms·
Yes, you can enable dumping the heap via command line arguments when starting the JVM: https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/clopt
by rockinghigh 8y ago
Yes, you can enable dumping the heap via command line arguments when starting the JVM: https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/clopts001.html https://docs.oracle.com/javase/8/docs/technotes/guides/troub...
- js8 8y agoWell, 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