Garbage collection

The Garbage Collection (GC) facility within the .NET Framework is in charge of releasing memory as objects run out of scope and are no longer used within an application. The fact that programmers have almost always needed to specifically free resources is the number one cause of memory leaks within an application. Thanks to the .NET Framework, this is all handled behind the scenes.

If this sounds too good to be true, the truth is that it may be. Although GC does free up memory, it does so at an undefined interval. Function calls available to the programmer enable a manual invocation of garbage collection but don't guarantee when it occurs.

On a positive note, included with the .NET Framework are performance counters that enable you to monitor garbage collection — when it runs, how long it runs, and the amount of memory it frees up, just to name a few aspects.

Was this article helpful?

0 0

Post a comment