Reputation: 102733
Working with a Java console application, I can do this:
java -agentlib:hprof=heap=dump,format=b MyClass
Then I can hit ctrl-\ (or ctrl-break on Windows) any time I would like to take a snapshot of the heap for later analysis.
I would like to do the same thing for a Java Web Start application, but I cannot seem to get that to work. I can pass in the agentlib argument with the JAVAWS_VM_ARGS environment variable, but entering ctrl-\ and ctrl-break in the console doesn't seem to do anything. All I get is one dump, when the program starts, which isn't really interesting since at that point I haven't even logged into our program yet and executed the transactions I want to analyze.
Upvotes: 0
Views: 1097
Reputation: 58058
Start your application with the following JMV arguments to enable JMX and boot a listener on port 9004:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port="9004"
-Dcom.sun.management.jmxremote.authenticate="false"
-Dcom.sun.management.jmxremote.ssl="false"
Then have a look at this Java program which can make a connection to the JMX server and take a heap dump on demand. The source code includes comments with links to 2 useful articles on the internet that helped me get all of this working. Good luck !
Link: JmxHeapDumper.java
P.S. apparently getting JMX to start for a WebStart app is tricky, I found this discussion, hope it helps: http://forums.java.net/jive/message.jspa?messageID=311717
Upvotes: 1