Debugging Memory Allocations

COM provides the IMallocSpy interface for developers to use to debug their memory allocations. For each method in IMalloc, there are two methods in IMallocSpy, a "pre" method and a "post" method. After a developer implements it and publishes it to the system, the system calls the IMallocSpy "pre" method just before the corresponding IMalloc method, effectively allowing the debug code to "spy" on the allocation operation, and calls the "post" method to release the spy.

For example, when COM detects that the next call is a call to IMalloc::Alloc, it calls IMallocSpy::PreAlloc, executing whatever debug operations the developer wants during the Alloc execution, and then, when the Alloc call returns, calls IMallocSpy::PostAlloc to release the spy and return control to the code.

Related topics

Managing Memory Allocation

 

 

Show: