C# apps are perfectly susceptible to memory leaks. They are different to old unmanaged C++ memory leaks, but they still happen and can be just as hard if not harder sometimes to find.  Instead of memory leaking and becoming lost to the system, in C# you can have memory the garbage collector running in the background never decides to release back to the OS because it thinks its still needed.

Objects that need disposing

Dispose Dispose Dispose!   If you've created and object and will then never need it again .dispose() of it.

Seach your project for "= null;" and if you are setting an object to null after use check to see if you can call ".Dispose()" first.

Event Handlers subscribed to objects

One common mistake is to not remove event handlers that subscribe to an object. An event handler subscription will prevent an object from being recycled.

Even if you are not assigning event handlers, do any methods you call and pass objects to do it to acomplish what they need to acheive?


Wrap objects that implement IDisposable in "using()" blocks?  


Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.


Your email address will not be published. Required fields are marked *