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?  


UK Electronic Designer
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.