How to get a thread and heap dump of a Java process on Windows that#39;s not running in a console(如何在 Windows 上获取不在控制台中运行的 Java 进程的线程和堆转储)
问题描述
我有一个从控制台运行的 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?
推荐答案
假设您知道 pid
,您可以使用 jmap
获取任何正在运行的进程的转储.
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.hprof <pid>
获取该进程的堆.
这篇关于如何在 Windows 上获取不在控制台中运行的 Java 进程的线程和堆转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Windows 上获取不在控制台中运行的 Java 进程的线程和堆转储


- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01