c# memory allocation and deallocation patterns
- by Neal
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?