Using HeapDumpOnOutOfMemoryError parameter for heap dump for JBoss
Here's what Oracle's documentation has to say:
By default the heap dump is created in
a file called java_pid.hprof in the
working directory of the VM, as in the
example above. You can specify an
alternative file name or directory
with the-XX:HeapDumpPath=
option. For
example-XX:HeapDumpPath=/disk2/dumps
will cause the heap dump to be
generated in the/disk2/dumps
directory.
Java EE heap dump on Out of Memory
How do I get this working in jave ee? Also should i get the heap dump when throwing new OutOfMemoryError?
If you're using JBoss, you should see the server.log and see if the exception is EJB or OOME, then try to fix it.
So we have:
How do I get this working in jave ee? See the exception.
Also should i get the heap dump when throwing new OutOfMemoryError? Yes, if you're correctly using the flag: -XX:+HeapDumpOnOutOfMemoryError
JAVA/OOM: How to dump all information on java heap space when it crashes due to OOM?
Use the HeapDumpOnOutOfMemoryError
and HeapDumpPath
options to generate a heap dump when an OutOfMemoryError
occurs in the JVM.
For example:
$ java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/some/path MyApp
If you suspect a memory leak, you can use jmap
, which is included with the JDK, to produce a heap dump of your application while it's running.
For example:
jmap -dump:live,format=b,file=dump.hprof <pid>
You can then analyze dump.hprof
using an application such as YourKit to pinpoint what code is causing the leak.
References
https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/clopts001.html
https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr014.html
How can I restart JVM on OutOfMemoryError _after_ making a heap dump?
java -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError="kill -9 %p" TestApp
JVM will dump heap first, and then execute OnOutOfMemoryError commands (proof).
Related Topics
Unresponsive Keylistener for Jframe
Eclipse 2021-09 Code Completion Not Showing All Methods and Classes
Why Is the Clone() Method Protected in Java.Lang.Object
Simple Popup Java Form with at Least Two Fields
Convert Java.Util.Date to What "Java.Time" Type
How to Change UI Depending on Combo Box Selection
How to Ask the Selenium-Webdriver to Wait for Few Seconds in Java
Javafx 11: Illegalaccesserror When Creating Label
Convert Float to String and String to Float in Java
What Is More Efficient, I++ or ++I
Problems Converting Byte Array to String and Back to Byte Array
Strange Floating-Point Behaviour in a Java Program
Using Heapdumponoutofmemoryerror Parameter for Heap Dump for Jboss
Why Does This Java Method Appear to Have Two Return Types
Java.Lang.Unsatisfiedlinkerror No *****.Dll in Java.Library.Path
Javafx Controller Class Not Working