Versions

[{“Name”:“1.0”,“GroupName”:”.NET”},{“Name”:“1.1”,“GroupName”:”.NET”},{“Name”:“2.0”,“GroupName”:”.NET”},{“Name”:“3.0”,“GroupName”:”.NET”},{“Name”:“3.5”,“GroupName”:”.NET”},{“Name”:“3.5 SP1”,“GroupName”:”.NET”},{“Name”:“4.0”,“GroupName”:”.NET”},{“Name”:“4.5”,“GroupName”:”.NET”},{“Name”:“4.5.1”,“GroupName”:”.NET”},{“Name”:“4.5.2”,“GroupName”:”.NET”},{“Name”:“4.6”,“GroupName”:”.NET”},{“Name”:“4.6.1”,“GroupName”:”.NET”},{“Name”:“4.6.2”,“GroupName”:”.NET”}]

Introduction

In .Net, objects created with new() are allocated on the managed heap. These objects are never explicitly finalized by the program that uses them; instead, this process is controlled by the .Net Garbage Collector.

Some of the examples below are “lab cases” to show the Garbage Collector at work and some significant details of its behavior, while other focus on how to prepare classes for proper handling by the Garbage Collector.

Remarks

The Garbage Collector is aimed to lower the program cost in terms of allocated memory, but doing so has a cost in terms of processing time. In order to achieve a good overall compromise, there are a number of optimizations that should be taken into consideration while programming with the Garbage Collector in mind: