JMap.java - Timed out while attempting to connect

2019-07-10 04:18发布

I'm trying to run and debug the utilies from sun.jvm.hotspot.tools and sun.jvm.hotspot.utilities (like JMap.java) in order to understand better what is going on.

Unfortunately I get stuck very early with the following error message and don't even get to debug a lot:

Attaching to process ID 5144, please wait...
Error attaching to process: Timed out while attempting to connect to debug server (please start SwDbgSrv.exe)

It seems like for whatever reason the tools are trying to connect to a "debug server" running on port 27000.

In the doc of the sun.jvm.hotspot.tools.HeapDumer.java I found the following:

This tool is used by the JDK jmap utility to dump the heap of the target process/core as a HPROF binary file. It can also be used as a standalone tool if required.

So I (maybe naively) assumed that jmap.exe is somehow using that, but I never had this kind of problems using creating a heap dump using jmap. I never needed to start another process first.

Any ideas what I need to do to run all those tools directly from my dev env?

Thanks

1条回答
虎瘦雄心在
2楼-- · 2019-07-10 04:39

sun.jvm.hotspot.* tools are the part of HotSpot Serviceability Agent.

I assume you use JDK 6 on Windows, because the debug server is no longer required since JDK 7. In earlier versions you had to start SwDbgSrv.exe in order to use Serviceability Agent.

Some built-in JDK utilities (jmap, jstack) have two execution modes: cooperative and forced. In normal cooperative mode these tools use Dynamic Attach Mechanism to connect to the target VM. The requested command is then executed directly by the target VM from within the target process.

The forced mode (jmap -F, jstack -F) behaves quite differently. The tool suspends the target process and then reads the process memory using Serviceability Agent. The command is executed in the tool's process while the target VM is paused. This is what sun.jvm.hotspot.* utilities do.

查看更多
登录 后发表回答