I'm trying to track down a memory leak in a COM object, and I'm not seeing anything obviously wrong. I'm probably using some of the COM wrappers incorrectly, but my standard toolkit of finding memory leaks (AQtime) isn't helping me with COM. Does anyone have any tricks/tools to track down COM memory/reference leaks?
+4
A:
If you're using ATL you can define _ATL_DEBUG_INTERFACES (see MSDN entry). This will certainly help you to catch any leaked interfaces, although obviously it won't help to catch any resources leaked internally within the object.
Stu Mackellar
2010-05-04 18:10:13
And if you're not using ATL or similar tools, start now and don't use manual COM handling.
Georg Fritzsche
2010-05-04 18:30:21
+1
A:
Check if the COM object(s) get released completely. Usually, AddRef+Release return the current reference count for debug purposes (you shouldn't rely on that for production code).
Otherwise, just general advice: reduce the code involved - do you get the leak whwen you just create and release the instance? After a certain method call?
peterchen
2010-05-04 18:13:47