This sample is located in \Samples\Profiler\Sampmon.
Note To use this sample, it is recommended that you have Microsoft® Visual C++® version 5.0 or higher installed.
Description
Using the Sample
Key Project Files
Technologies Demonstrated
This sample defines a simple implementation of the following Microsoft virtual machine (Microsoft VM) event monitor interfaces:
To compile the sample
Use Nmake.exe to compile the makefile in the base directory \Samples\Profiler\Sampmon. Type the following command:
Nmake
To install the sample
regsvr32 Sampmon.dll
To uninstall the sample
regsvr32 /u Sampmon.dll
To run the sample
Run some code you want to profile; the sample monitor's output appears on stdout. The output can be controlled by setting various values under HKEY_CURRENT_USER\Software\Microsoft\Java VM\Monitors\SampleMonitor, a registry key which you can create with regedit or regedt32.
The following table shows the recognized values (all are DWORD except for SpecificMethods, which is a String.)
RequestedEvents | A bitmask of flags from JAVA_EVENT_CATEGORY (see Jevmon.idl or the profiler documentation in the Microsoft SDK for Java). For example, if this value is set to JVM_MONITOR_CLASS_LOADS, all class load events will be displayed. The default value is ALL_JVM_MONITOR_EVENTS. |
DumpObjectHeap | If set to a non-zero value, the heap is dumped after each garbage collection. The default value is 1. |
FollowObjectReferences | If heap dumping is enabled, this enables depth-first traversal of the references. The default value is 0. |
DisplayObjectAllocations | If set to a non-zero value, outputs a stack trace at each object allocation. The default value is 1. |
SamplingFrequency | Frequency to sample method locations in milliseconds. If set to 0 (zero), sampling is disabled. The default value is 100. |
SampleData | If sampling is enabled, this is a bitmask of flags from JVM_METHOD_SAMPLE_FLAGS indicating the sampling information to obtain and display. The default value is ALL_JVM_SAMPLE_FIELDS. |
SpecificMethods | A list of specific methods to display entry/exit for. Each method must be specified by its fully-qualified name, e.g. java/lang/Math.round(D)J. The names must be separated by commas. |
Contains the C code that implements the profiler COM interfaces for monitoring the Microsoft VM. This code will be compiled into the Sampmon.dll file that will be registered for doing the work in this sample.
sampmon.defLists the functions exported by the Sampmon dll. These functions are for registering the COM object with the Regsvr32.exe tool.
sampmon.idlImports the IDL definitions from Jevmon.idl; contains an interface definition for ISampleJavaEventMonitor.