Memory Leaks C# [closed]

There are many kinds of memory leaks, but in general the term refer to some kind of resource that is no longer used, but still takes up memory. If you have many of those your application takes a lot of memory and eventually you run out of it.

In C#, these are some common memory leaks:

  • Not removing event listeners. Any event listener that is created with an anonymous method or lambda expression that references an outside object will keep those objects alive. Remember to remove event listeners when they are no longer used.
  • Keeping database connections or result sets open when they are not used. Remember to call Dispose() on all IDisposable objects. Use the using statement.
  • Call to C functions using p/Invoke which allocate memory which you then never release.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)