Hi,
What are the best ways for a .NET developer to hunt down (and avoid) unmanaged leaks in a managed app?
There seem to be many excellent resources for tracking down managed leaks, but I haven't found much on tracking unmanaged leaks in a managed app.
This question is related, but asks the question from a purely unmanaged point of view, so many of the answers assume that you have access to unmanaged code, and none mention any .NET-specific pitfalls or techniques.
Here are some (very basic) things I have tried:
- DebugDiag. It looks very promising, and it may work for you, but it happens to crash my particular app.
- Rational PurifyPlus. Sadly, also crashes my app.
- AQTime (at the recommendation of @Reed and @Caelum). This program looks fabulous, but, like the poster of the question @Caelum mentioned, AQTime also crashes my app.
- Temporarily remove code that creates objects that I know use unmanaged memory.
- Ensure that the app is disposing all objects that implement
IDisposable
I should mention that I was able to successfully profile another managed app (which was leaking unmanaged memory) using the profilers above. Please give them a try if you've got an unmanaged leak.