如何在未在控制台中运行的 Windows 上获取 Java 进程的线程和堆转储 [英] How to get a thread and heap dump of a Java process on Windows that's not running in a console

查看:24
本文介绍了如何在未在控制台中运行的 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 进程的线程和堆转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆