Chapter 18. Garbage Collection

One of the most useful features of C# (and .NET more generally) is automatic memory management. When you create a new object, the memory required to store it is allocated automatically. You don't need to do anything specific when you have finished working with the object. The .NET runtime takes care of releasing the memory that the object was using for you.

The part of the .NET runtime that handles releasing memory is called the garbage collector (GC), and it generally works without you being aware that it is there and without you having to intervene in its operation. There are times, however, when an understanding of garbage collection can be useful, and there are some explicit steps you can take to help the garbage ...

Get Introducing Visual C# 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.