Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to track down COM memory leak

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?

like image 809
Steve Avatar asked May 04 '10 18:05

Steve


People also ask

How do I find a memory leak on my website?

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.

What is the best tool to detect memory leaks?

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.

How do I find a memory leak app?

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.


2 Answers

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.

like image 123
Stu Mackellar Avatar answered Sep 28 '22 03:09

Stu Mackellar


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?

like image 34
peterchen Avatar answered Sep 28 '22 01:09

peterchen