Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
565 views
in Technique[技术] by (71.8m points)

monitoring - Get heap dump from a remote application in Java using JVisualVM

I run JVisualVM (Windows XP, Sun Java 1.6.0.13, 32 bit client VM) to monitor a distant application (Linux, Sun Java 1.6.0.07, 64 bit server VM). Before starting the actual remote application, I launch on the remote machine jstatd using an all access policy:

grant codebase "file:${java.home}/../lib/tools.jar" {
   permission java.security.AllPermission;
};

Then I start the actual app using the command line

 java -Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.port=3333 
compileTest.Main

From the client machine, I can see the distant app and monitor it. I can also make a thread dump etc. Unfortunately, the heap-dump button is grayed out.

How can I obtain a heap-dump from a remotely monitored application using JVisualVM?

I tried using jConsole. With jConsole it is possible to make a distant heap dump using the com.sun.management.HotSpotDiagnostic dumpHeap operation. I want the dump to be transferred to the client side and analyzed using the tools provided by JVisualVM. How can I do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There is a way to do it!

  1. rmiregistry -J-Xbootclasspath/p:$JAVA_HOME/lib/sa-jdi.jar ( this uses port 1099)
  2. start 'jsadebugd' on the machine in which application is running: jsadebugd & (pid of JVM)
  3. On remote machine use following jmap -dump:file= :1099

  4. jhat

The above will start a web application at port 7000

All the above tools are part of JDK 1.6

All the best!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...