4.2. Garbage Collection

Garbage collection is something you rarely have to worry about in our nice managed world, so before you look at what has changed in .NET 4.0, let's quickly recap how garbage collections currently works to put the new changes in context.

4.2.1. Garbage Collection Prior to .NET 4.0

As you probably know, the CLR allocates memory for your applications as they require it, and assumes that an infinite amount of memory is available (you wish). This is a mad assumption, so a process called the garbage collector (GC) is needed in order to clean up unused resources. The GC keeps an eye on available memory resources and will perform a cleanup in three situations:

  • When a threshold is exceeded

  • When a user specifically calls the GC ...

Get Introducing .NET 4.0: with Visual Studio 2010 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.