Is it possible to view threads from hprof dump / threads in heap dump
Asked Answered
C

7

10

I have got a large (5GB) hprof dump, created by application when OutOfMemoryError occurred. (Using XX: HeapDumpOnOutOfMemoryError ).

Unfortunately there are no logs collected when this error happened. Re-creating this will take couple of hours. I was hoping if some tools could show the exception stack trace or all threads stacks etc from hprof.

I am currently using MAT, could not see a way to get thread information. Which tool I could use?

(I am not sure if hprof file has information about thread/location of call when OOM occurred).

( I do know to how to take thread dump in normal cases. The trouble here is the event already happened, all I have is the hprof dump. )

Cletis answered 12/9, 2012 at 5:5 Comment(3)
Try visualvm (docs.oracle.com/javase/6/docs/technotes/guides/visualvm/…)Sculptress
Heap dump doesn't contain thread information. You should look at thread dump.Numb
@ RC . yes, loaded hprof using VisualVM and it has option to show thread dumps. Could you mark as answer?Cletis
J
9

MAT can show the threads directly now (perhaps this was added since the question was asked).

Threads Overview

To get an overview of all the threads in the heap dump use the "Thread Overview" button in the toolbar, as shown on the image below. Alternatively one could use the Query Browser > Thread Overview and Stacks query:

screenshot of toolbar icon

Jeffryjeffy answered 20/12, 2016 at 13:44 Comment(3)
!! Finally actual answer to my question :)Cletis
Also, all stacktraces (with some additional information) are in .threads file in MAT parsing directoryBrail
Anyone know if you can export these in the common threaddump format that you would get with kill -3 or jstack? We looked at the .threads file but it didn't parase as a standard threaddump in the program we use to analyze those.Midst
C
13

Answering own question. Credit goes to @ RC

  1. Open the dump using visualvm. It takes a while.
  2. click on "threads at heap dump"

visual vm with threads at heapdump

Cletis answered 12/9, 2012 at 6:53 Comment(2)
https://mcmap.net/q/772024/-does-a-java-heap-dump-include-thread-stacks say that this is "new" feature of heap dump format (dated near 2010).Sequin
For long this was the answer. Now MAT has improved the reporting .. see answer from @matt b : #12382034Cletis
J
9

MAT can show the threads directly now (perhaps this was added since the question was asked).

Threads Overview

To get an overview of all the threads in the heap dump use the "Thread Overview" button in the toolbar, as shown on the image below. Alternatively one could use the Query Browser > Thread Overview and Stacks query:

screenshot of toolbar icon

Jeffryjeffy answered 20/12, 2016 at 13:44 Comment(3)
!! Finally actual answer to my question :)Cletis
Also, all stacktraces (with some additional information) are in .threads file in MAT parsing directoryBrail
Anyone know if you can export these in the common threaddump format that you would get with kill -3 or jstack? We looked at the .threads file but it didn't parase as a standard threaddump in the program we use to analyze those.Midst
O
0

I don't think heap dump contains thread information except GC root. If you need thread related information, you need to take thread dump also.

Oby answered 12/9, 2012 at 5:7 Comment(0)
E
0

Eclipse MAT allows you to see the suspect threads in the Leak suspects report. Look for the classes in your application namespace with their line numbers to find how much memory they occupy in heap. This will give you a hint of leaky classes.

Earley answered 12/9, 2012 at 5:26 Comment(0)
O
0

You can kill -3 the process id to get a thread dump to standard out. This will not kill the java process so you can do it as many times as you want.

as RC stated visualVM is a good tool which will give you Object counts by class type and all kinds of graphs and profiling tools.

Ohaus answered 12/9, 2012 at 5:27 Comment(0)
O
0

Use visualvm.

try to analyse the graph when perm heap space exceeds... u should also check the memory samples & save its snapshot..

Analysis the thread stack... will help you narrow down to the problem.

Organist answered 12/9, 2012 at 6:40 Comment(0)
T
-1

To turn on an option your need + and to turn off an option you need -

What is confusing about the documentation is that it shows the default setting to make it "clear" what setting you have already. The ones with + are on by default and the ones with - are off by default. This means if you copy any of the + or - options from the documentation they should do nothing (except where the default has changed over time)

-XX:-HeapDumpOnOutOfMemoryError turns off the heap dump, which is the default.

-XX:+HeapDumpOnOutOfMemoryError turns on the heap dump.

Trahurn answered 12/9, 2012 at 7:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.