Sample Monitor

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

Description

This sample defines a simple implementation of the following Microsoft virtual machine (Microsoft VM) event monitor interfaces:

Using the Sample

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

  1. Use the Regsvr32.exe tool to register the event monitor:

    regsvr32 Sampmon.dll

  2. To activate the event monitor, the DWORD registry value HKEY_CURRENT_USER\Software\Microsoft\Java VM\EnableEventMonitors must be set to a non-zero value.

  3. See the profiler documentation in the Microsoft SDK for Java for more information about the installation and activation of profilers.

To uninstall the sample

  1. Use the following command to remove the event monitor from the registry:

    regsvr32 /u Sampmon.dll

  2. Remove the registry key HKEY_CURRENT_USER\Software\Microsoft\Java VM\EnableEventMonitors or set its value to 0 (zero).

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.

Key Project Files

sampmon.cpp

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.def

Lists the functions exported by the Sampmon dll. These functions are for registering the COM object with the Regsvr32.exe tool.

sampmon.idl

Imports the IDL definitions from Jevmon.idl; contains an interface definition for ISampleJavaEventMonitor.

Technologies Demonstrated

Profiler

© 1999 Microsoft Corporation. All rights reserved. Terms of use.