In my UMDF
driver i have a IWDFMemory
packed inside a CComPtr
CComPtr<IWDFMemory> memory;
The documentation of CComPtr
says, If a CComPtr
object gets out of scope, it gets automagically freed. That means this code should not create any memory leaks:
void main()
{
CComPtr<IWDFDriver> driver = /*driver*/;
/*
driver initialisation
*/
{
// new scope starts here
CComPtr<IWDFMemory> memory = NULL;
driver->CreateWdfMemory(0x1000000, NULL, NULL, &memory);
// At this point 16MB memory have been allocated.
// I can verify this by the task manager.
// scope ends here
}
// If I understand right the memory I allocated in previous scope should already
// be freed at this point. But in the task manager I still can see the 16 MB
// memory used by the process.
}
Also if I manually assign NULL
to memory
or call memory.Release()
before scope end the memory does not get freed. I am wondering what is happening here?