Garbage Collection in a Nutshell

As mentioned previously, the .NET runtime features automatic memory management using a garbage collector. The advantages of the service should not be underestimated because whole classes of bugs get eliminated by it. Examples of common memory management issues that come to mind include leaking objects or freeing objects multiple times (a “double free”).

Conceptually, the garbage collected memory heap gives you the illusion of an infinite memory space from which you can allocate as much as needed. Obviously, resources are limited. Not as limited as the physical memory, obviously, because today’s operating systems offer memory virtualization mechanisms. But still, the party can’t last forever. Instead of having ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.