Microsoft and Garbage Collection
The .NET developer doesn’t usually have to understand how the Microsoft “Garbage Collector” (GC) works to build an app, but occasionally a situation arises where understanding garbage collection in the context of app development is beneficial. Garbage collection in Microsoft’s .NET development framework is an automatic process that frees up memory that an application no longer needs.
Sometimes memory is allocated to an object in .NET even after that object is no longer needed by an application. But the memory occupied by the object can’t be reused unless it is specifically freed up. Without periodic freeing up of memory that’s taken up by unused objects, applications can run out of memory and crash. The .NET GC is designed to do this in the background, so app developers can build most of their apps without having to worry about managing or freeing up memory.
How Does .NET Determine What Qualifies as Garbage?