Article ID: 317866 - Last Review: December 6, 2006 - Revision: 5.2

Roadmap for garbage collection in the Microsoft .NET Framework

This article was previously published under Q317866

On This Page

Expand all | Collapse all

SUMMARY

This article provides a roadmap to learn and master garbage collection in the Microsoft .NET Framework. To help you with learning a Microsoft product or technology, roadmap articles provide links to useful information, including online documentation, Microsoft Knowledge Base (KB) articles, and white papers.

This article contains the following sections:

Overview

Unlike COM, the common language runtime does not use reference counting to govern object lifetime. Instead, the garbage collector traces object references and identifies objects that can no longer be accessed by running code. This simplifies component programming a great deal, because you do not have to worry about circular references. If you use a group of objects in which the objects contain references to each other, but none of these objects are referenced directly or indirectly from stack or shared variables, garbage collection automatically reclaims the memory.

Therefore, garbage collection in .NET completely relieves the developer from the responsibility of tracking memory usage and determining when to release memory. However, it is important that you understand how garbage collection works. The following links provide overview information about garbage collection in Visual Studio .NET:
Reference counting, garbage collection, and object lifetime
http://msdn2.microsoft.com/en-us/library/0t81zye4(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/0t81zye4(VS.71).aspx)

Object lifetime: How objects are created and destroyed
http://msdn2.microsoft.com/en-us/library/hks5e2k6.aspx (http://msdn2.microsoft.com/en-us/library/hks5e2k6.aspx)

Garbage collection: Automatic Memory Management in the Microsoft .NET Framework Part-1
http://msdn.microsoft.com/en-us/magazine/bb985010.aspx (http://msdn.microsoft.com/en-us/magazine/bb985010.aspx)

Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework Part-2
http://msdn.microsoft.com/en-us/magazine/bb985011.aspx (http://msdn.microsoft.com/en-us/magazine/bb985011.aspx)

Architecture

The following links provide architectural information about the garbage collector in .NET:
Developer backgrounds in Memory Management
http://msdn2.microsoft.com/en-us/library/aa719967(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/aa719967(VS.71).aspx)

Initialization and Termination of Components
http://msdn2.microsoft.com/de-de/library/ws9dc6t6(VS.71).aspx (http://msdn2.microsoft.com/de-de/library/ws9dc6t6(VS.71).aspx)

Automatic Memory Management
http://msdn2.microsoft.com/en-us/library/aa719614(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/aa719614(VS.71).aspx)

Key concepts

The following links lead to documentation about key .NET garbage collection concepts:
Programming for garbage collection
http://msdn2.microsoft.com/en-us/library/aa720427(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/aa720427(VS.71).aspx)

Forcing a garbage collection
http://msdn2.microsoft.com/en-us/library/aa720082(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/aa720082(VS.71).aspx)

GC class
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemGCClassTopic.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemGCClassTopic.asp)

Cleaning up unmanaged resources
http://msdn2.microsoft.com/en-us/library/aa719699(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/aa719699(VS.71).aspx)

Finalize methods and destructors
http://msdn2.microsoft.com/en-us/library/aa720079(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/aa720079(VS.71).aspx)

Garbage collection technology sample
http://msdn2.microsoft.com/en-us/library/aa701052(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/aa701052(VS.71).aspx)

How to articles

How To articles provide step-by-step instructions for performing specific tasks. Run the following Microsoft Knowledge Base query to return How To articles about Visual Studio .NET. After you have reached the query page, you can narrow your search by providing additional search criteria:
How to find answers online
http://support.microsoft.com/default.aspx?scid=%2Fsupport%2Fhowto%2Fservices.asp (http://support.microsoft.com/default.aspx?scid=%2fsupport%2fhowto%2fservices.asp)

Troubleshooting

If you experience problems, you can visit Microsoft newsgroups, where you can share your experiences with your peers, or you can search the Microsoft Knowledge Base (KB) for KB articles about specific issues:
MSDN Newsgroups
http://msdn.microsoft.com/newsgroups/ (http://msdn.microsoft.com/newsgroups/)

Microsoft Knowledge Base
http://support.microsoft.com/search (http://support.microsoft.com/search)

APPLIES TO
  • Microsoft .NET Framework 1.1
  • Microsoft Common Language Runtime (included with the .NET Framework) 1.0
Keywords: 
kbgarbagecollect kbinfo KB317866
 

Article Translations

 

Related Support Centers