Hi,
I've been working on the hprof implementation of the Kato API, and
one thing I'd like to do is to be able to generate a complete hprof file
programmatically. By complete, I mean threads as well as the heap.
So far I've found that with HotSpot we can generate hprof files with the
following methods:
-XX:+HeapDumpOnOutOfMemoryError - so generate an hprof file with
just the heapdump
CTRL+Break - to initiate the agent to generate a complete dump.
And I've found that JMX can be used to generate an hprof file
programmatically with only the heap, like so:
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
mbeanServer.invoke(ObjectName.getInstance("com.sun.management:type=HotSpotDiagnostic"),
"dumpHeap",
new Object[] {"java.hprof",false},
new String[] {"java.lang.String","boolean"});
Unfortunately, the API would normally be even less complete with hprof
because of this problem. I presume that this is a fundamental limitation
of how the JVM operates, but I thought I'd mention it in case someone
knew any tricks.
Thanks,
Stuart