How to find the dll which causes a memory leak and not directly referenced by application

811 views Asked by At

I am writing a WPF application which uses a number of unmanaged DLL's. Something in the program is causing memory leak and I monitored the application using Redgate ANTS 8 Memory Profiler. ANTS shows that the memory usage of MSVCR110.dll is constantly increasing.

The question is that can managed code cause this leak by using MSVCR110.dll?

If not can I find which of the unmanaged dll's is using MSVCR110.dll and causing leak?

(My program has reference to MSVCR110.dll directly.)

2

There are 2 answers

0
Yusuf Tarık Günaydın On BEST ANSWER

The answer was not easy to find. I had tried each DLL that I suspected one by one. The leak was an undeleted array in a C++/CLI wrapper class. Since it is a managed dll, I think, the native "new" calls are traced through msvcr110.dll, and ANTS shows leak in that dll.

0
CharithJ On

Take a few Snapshots and see if there is any growth in any managed objects. You can select objects with source options in ANTS memory profiler and if instance count it growing for any of your objects. And then, you can have a look at the ‘Instance Retention graph’ for any of growing instance and see which holds the reference.

And also, make sure you unsubscribe from any subscription you make to the third party components and call dispose and set null pointers appropriately.