Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
590 views
in Technique[技术] by (71.8m points)

elasticsearch - How to take a heap dump in windows with minimum downtime?

I want to figure out why JVM heap usage on Elasticsearch node is staying consistently above 80%. In order to do this, I take a heap dump by running

jmap.exe -heap:format=b 5348

(5348 is the Process ID). Then I can analyze the dump with VisualVM.

The problem is that jmap pauses the JVM while taking the dump, so the node is basically offline for around 5 minutes.

This article suggests a faster approach that relies on taking coredump with gdb on Linux. I already tried WinDbg, which created a core dump, but I couldn't use it in VisualVM.

Is there a similar approach for Windows? How one can take heap dumps in seconds, not minutes?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

After you've taken the coredump by WinDbg, you need to extract the heap dump from it by running

jmap -heap:format=b "C:Program FilesJava...injava.exe" core.mdmp

This could be done offline; no interaction with running Java process needed. Then you will be able to open the generated heap.bin in VisualVM.


Alternatively you may take the class histogram. It is produced a way faster than full heap dump.

jmap -histo <PID>

It shows you the list of classes whose instances occupy the most space in the heap. This information is often enough to get the idea of where's the memory lost.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...