The JVM Tool Interface (JVM TI): How VM Agents Work Tech Tip
A December tech tip article explains some basics of writing a JavaTM Virtual Machine (JVMTM) tool interface (JVM TI) agent library by walking through the heapTracker demo agent available in the JDK downloads. Senior staff engineer Kelly O-Hair and writer Janice Heiss provide code samples as well in "The JVM Tool Interface (JVM TI): How VM Agents Work".
Tips include being cautious about how much memory to allocate. Too much will cause the VM process to fail. Also, make sure the process can locate the library.
A DVM agent is not needed because the JDK 6 release includes "virtually all the required built-in DTrace probes", according to the authors.
A code sample (abbreviated) shows what agent initialization looks like.
Also in the tech tip are:
Event Callbacks, code for cbClassFileLoadHook
How to set up the Tracker class for the VM start event
The importance of knowing what the stack trace is and to tag the object with a reference to that information
Customized news reports about Sun Microsystems. Just the news you need, none of what you don't. 50,000+ Members. 20,000+ Articles Published since 1998.