如何在Windows中进行堆转储,停机时间最短? [英] How to take a heap dump in windows with minimum downtime?
问题描述
jmap.exe -heap:format = b 5348
(5348是进程ID)。然后我可以使用VisualVM分析转储。
问题是,在执行转储时,$ code> jmap 暂停JVM,所以节点基本上离线了大约5分钟。
本文提出了一种更快速的方法,它依赖于在Linux上使用 gdb
的coredump。我已经尝试过WinDbg,它创建了一个核心转储,但是我无法在VisualVM中使用它。
Windows有类似的方法吗?
在使用coredump后,您可以使用 WinDbg
,您需要通过运行
jmap -heap:format来提取堆转储= bC:\Program Files\Java\ ... \bin\java.execore.mdmp
这可以离线完成;不需要与运行的Java进程交互。然后,您将可以在VisualVM中打开生成的 heap.bin
。
或者,您可以使用类别直方图。它的产生速度比完全堆转储速度快。
jmap -histo< PID>
它显示了实例占用堆中最多空间的类的列表。这个信息通常足以让你知道内存丢失的位置。
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?
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 Files\Java\...\bin\java.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.
这篇关于如何在Windows中进行堆转储,停机时间最短?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!