问题描述
我有一个Java应用程序,我从控制台运行,而控制台又执行另一个Java进程。我想获得该子进程的线程/堆转储。
I have a Java application that I run from a console which in turn executes an another Java process. I want to get a thread/heap dump of that child process.
在Unix上,我可以执行 kill -3< pid>
但是在Windows AFAIK上,获取线程转储的唯一方法是在控制台中使用Ctrl-Break。但是这只给了我父进程的转储,而不是子进程。
On Unix, I could do a kill -3 <pid>
but on Windows AFAIK the only way to get a thread dump is Ctrl-Break in the console. But that only gives me the dump of the parent process, not the child.
是否有其他方法可以获得堆转储?
Is there another way to get that heap dump?
推荐答案
您可以使用 jmap
来获取正在运行的任何进程的转储,假设您知道 pid
。
You can use jmap
to get a dump of any process running, assuming you know the pid
.
使用任务管理器或资源监视器获取 pid
。那么
Use Task Manager or Resource Monitor to get the pid
. Then
jmap -dump:format=b,file=cheap.bin <pid>
获取该流程的堆。
这篇关于如何在Windows上获取未在控制台中运行的Java进程的线程和堆转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!