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?
Start with metrics such as page load times, HTTP request times, and Core Web Vitals – time to the first byte, first contentful paint. If you use Sematext Experience you'll see a number of other useful metrics for your web applications and websites there. However, metrics themselves are only a part of the whole picture.
To find memory leaks and inefficient memory usage, you can use tools such as the debugger-integrated Memory Usage diagnostic tool or tools in the Performance Profiler such as the . NET Object Allocation tool and the post-mortem Memory Usage tool.
The Memory Profiler is a component in the Android Profiler that helps you identify memory leaks and memory churn that can lead to stutter, freezes, and even app crashes. It shows a realtime graph of your app's memory use and lets you capture a heap dump, force garbage collections, and track memory allocations.
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.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With