For the Microsoft VM to communicate with a memory profiler, the profiler must register heap monitoring callback interfaces with the Microsoft VM. When events occur for which the profiler has indicated it wants to be notified, methods implemented by the profiler are called by the Microsoft VM. For specific interfaces and their methods, see the Heap Monitor Notification Profiler Interfaces Reference.
The profiler can use the ObjectID and ClassID returned from the OnObjectAllocated method and call any of the profiler methods that take an ObjectID or ClassID to get more information on this object. For example, calling ClassInformation with the ClassID can be used to determine if this object is an instance of a class or an array. If the class name begins with a left bracket ([), this object is an array.
The ObjectID for an object on the heap can change after garbage collection. This can occur at any time, even immediately after returning from the OnObjectAllocated method. If ObjectIDs are to be reused, use GetHandlesToObjects to get persistent handles to the objects.
A profiler registers IHeapInfoCallBack to be informed by the VM that garbage collection has completed, and then receive a heap dump.