In a java heap dump how do I know exactly where in the code/which thread caused the dump?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For reading the memory dumps:
I would recommend you to try "eclipse memory analyzer" From here
Another option (free) would be opening this with JVisualVM (available at $JAVA_HOME/bin)
jhat is cool too but was already recommended 🙂
Now, you’re asking about the thread that caused memory heap-dump and not about how to proceed with memory dump…
It depends on how did you obtain the memory dump.
There are different ways to obtain the dump.
On your process you can instruct the JVM to produce memory dump once OutOfMemory error is encountered, in this case I believe it will be the JVM itself.
You can trigger the heap dump creation from the MBean given you have a JMX Server running along with your JVM
Example
You can even use system calls (on linux) externally to your application:
kill -3 _YOUR_JAVA_PROCESS_ID_will generation the heapdump.But I hardly can imagine why would you need such an information. Later in comments you mention ‘exact line of code’ but these ways are usually external to your JVM… Are you sure you need a line of code that generated heap dump itself, or you’re trying to identify the real issue?
Hope this helps