1

I've got a JBoss 4.2.1 application running on a JVM 7 that has triggered heap dumps when it throws OutOfMemoryExceptions. I have the jvm configured with the following switches:

-Xms1498m -Xmx3000m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError

I am trying to read through the heap dumps to figure out exactly what caused my OOME. I see large blocks of memory consumed, but they are somewhat expected. What I am looking for at the moment is the "smoking gun".

I've already opened another SO issue here regarding missing memory in my heap dump, so I'm trying to figure out what the JVM was doing when the OOME occurred.

Is there anything in the heap dump that would indicate which thread triggered the OOME? More specifically what the call that triggered my OOME was doing? I realize and understand that in the case of memory leaks, this might be chasing the wrong trail, but I'm looking to see if I see which thread caused the exception.

Is there anyway to use MAT to see this?

Community
  • 1
  • 1
Eric B.
  • 23,425
  • 50
  • 169
  • 316

2 Answers2

1

Have you checked the thread overview in MAT? Thread Overview

It won't tell you the thread that triggered the OOME but will give info on retained heap.

SVashisth
  • 131
  • 10
  • 1
    Yes - I've been looking at the Thread overview; thanks. But it doesn't tell me which thread triggered the OOME - just which threads were executing what. And given that I have 258 threads listed, it is quite difficult to look through each thread to determine what each was doing. I am able to sort by Retained Heap size, but that just tells me which thread was consuming the most memory. It doesn't tell me which thread made my JVM crash. – Eric B. Jun 07 '16 at 14:23
  • Do you see something like
    Exception in thread "main": java.lang.OutOfMemoryError in your stack trace?
    – SVashisth Jun 07 '16 at 14:48
  • Unfortunately not. I just see the stack trace, and the cause (Caused by: java.lang.OutOfMemoryError: Java heap space) but not the offending thread name/number. – Eric B. Jun 07 '16 at 15:02
1

We don't really care actually which thread causes the OOME as it would not prove anything, think about a thread that does a simple task with no leak, if the heap is already nearly full and this thread creates even a small Object it could cause the OOME without being the root cause of the memory leak.

Regarding your actual question I don't believe that you can know which Thread caused the OOME from a heap dump, the only way is to check your console or your log file as the JVM prints the stack trace into the standard output on OOME.

Nicolas Filotto
  • 43,537
  • 11
  • 94
  • 122
  • As I indicated above, I realize that in an `OOME`, that the thread causing the `OOME` may not prove anything. However, I am trying to correlate several different dumps, and if I can see a pattern (ex: a thread trying to allocate huge blocks of memory) causing an `OOME` it might help narrow down my focus. Of course, as you mentioned, it might not have anything to do with that. – Eric B. Jun 07 '16 at 15:03
  • read this it may help http://stackoverflow.com/questions/37593549/java-heap-and-thread-analysis-for-memory-leak/37665594#37665594 – Nicolas Filotto Jun 07 '16 at 15:20