What are all the possible ways to troubleshoot memory leaks in .NET?
I know two:
Example:
// Causes Leaks Label label = new Label(); this.Controls.Add(label); this.Controls.Remove(label); // Correct Code Label label = new Label(); this.Controls.Add(label); this.Controls.Remove(label); label.Dispose();
Refresh . The idea is to list common errors that are not too obvious (like above). Usually, the concept is that memory leaks are not a big problem due to the garbage collector. It doesn't seem to be in C ++.
Great discussion guys, but let me clarify ... by definition, if there is no object reference in .NET, it will be garbage collection at some point. Therefore, this is not a way to cause a memory leak.
In a managed environment, I will consider a memory leak if you had an inadvertent reference to any object you don't know about (here are two examples in my question).
So, what are the different possible ways of a memory leak?
Vaibhav Aug 21 '08 at 16:11 2008-08-21 16:11
source share