c# memory allocation and deallocation patterns
Posted
by Neal
on Stack Overflow
See other posts from Stack Overflow
or by Neal
Published on 2010-04-27T00:09:37Z
Indexed on
2010/04/27
0:13 UTC
Read the original article
Hit count: 438
Since C# uses Garbage Collection. When is it necessary to use .Dispose to free the memory?
I realize there are a few situations so I'll try to list the ones I can think of.
- If I close a Form that contains GUI type object, are those objects dereferenced and therefore will be collected?
- If I create a local object using new should I .Dispose of it before the method exits or just let the GC take care of it? What is good practice in this case?
- Are there any times in which forcing a GC is understandable?
- Are events collected by the GC when it's object is collected?
© Stack Overflow or respective owner