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 进程的线程和堆转储
基础教程推荐
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- JPA惰性列表上的流 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
