The heap monitoring interfaces allow a memory profiler to collect detailed information on heap memory usage and garbage collection activity for a Java process. The heap monitoring interfaces allow a memory profiler to receive notification on each object allocation, to track when garbage collections occur, and to retrieve a detailed heap dump after garbage collection.
The heap monitoring interfaces are COM interfaces implemented by the Microsoft VM and a memory profiler (callback routines).
Heap monitoring follows a conceptual model similar to the other profiler interfaces. A memory monitoring application must register with the Microsoft VM, indicating an interest in receiving notifications for heap monitoring and its heap information callback interface. The Microsoft VM will communicate with the profiler through this callback interface. The profiler must register separate callbacks to receive notification when objects are created and for receiving a heap dump after garbage collection.
The heap monitoring interfaces make extensive use of the concept of containers for representing heap usage. Through these containers, a memory profiler can completely rebuild the containment hierarchy for heap memory starting from root containers. Container types are defined for threads, static class references, objects awaiting finalization, internal VM objects, and various stack frames such as native garbage collection and the JIT-compiled, native, COM, interpreted, and fast interpreted methods.
The following sections describe in detail how to use the Java heap monitor interfaces. They include discussion of the following topics:
Registering with the Heap Monitor shows how to determine if the Microsoft VM supports heap monitoring.
Implementing HeapInfo and Object Allocation Callback Interfaces discusses how the Microsoft VM communicates with a memory profiler.