Reputation: 7030
I've ran a profiler (CLR Profiler 4.0) on my C# application and after the application has been terminated, I was left with the following statistics:
Handles Created: 34,126 Handles Destroyed: 32,844 Handles Surviving: 1,282
I'm under the impression that handles surviving should reach near zero when the program terminates. Am I wrong about this? What are some other indicators that my application is not leaking any memory?
Upvotes: 3
Views: 355
Reputation: 2964
Those are the surviving handles just before closing the app. That does not mean your app is leaking memory, all handles, application domains, and other "managed" resources living in the process will be cleaned up. If you have called any native dll's or used other "unsafe" code blocks (unmanaged resources), you have to make sure you release those resources in your code (you can use destructors or the IDisposible interface to do that).
I suggest you start reading from page 44 in "Under the hood of .NET Memory Management" starting from the heading "Generational garbage collection". That should somewhat clear up those results.
Upvotes: 2