Is it possible to view threads from hprof dump / t

2019-03-15 23:33发布

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. )

7条回答
唯我独甜
2楼-- · 2019-03-16 00:00

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

查看更多
一夜七次
3楼-- · 2019-03-16 00:03

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.

查看更多
冷血范
4楼-- · 2019-03-16 00:04

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

查看更多
Bombasti
5楼-- · 2019-03-16 00:05

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.

查看更多
ら.Afraid
6楼-- · 2019-03-16 00:07

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.

查看更多
我命由我不由天
7楼-- · 2019-03-16 00:10

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.

查看更多
登录 后发表回答