---
source: https://iinventedlight.com/library/notes/dotnet-garbage-collection.md
title: ".NET garbage collection and generations"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC BY 4.0 (dotnet/docs); prose restates or closely paraphrases cited source lines"
license_family: dotnet-docs-ccby
rule_check: "needs rule check (family not in auto-publish rule; check.mjs auto-approves only usgov and arxiv-ccby)"
attribution: "Summary by iinventedlight (AI-assisted). Sources: Microsoft Learn (.NET docs), Fundamentals of garbage collection - .NET, CC BY 4.0 (dotnet/docs); Microsoft Learn (.NET docs), .NET garbage collection - .NET, CC BY 4.0 (dotnet/docs)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: .NET"
tags: ['dotnet', 'garbage-collection', 'memory']
sources:
  - id: S1
    title: "Fundamentals of garbage collection - .NET"
    publisher: Microsoft Learn (.NET docs)
    url: https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/fundamentals
    accessed: 2026-11-04
    license: "CC BY 4.0 (dotnet/docs)"
  - id: S2
    title: ".NET garbage collection - .NET"
    publisher: Microsoft Learn (.NET docs)
    url: https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/
    accessed: 2026-11-04
    license: "CC BY 4.0 (dotnet/docs)"
---
# .NET garbage collection and generations

**Answer:** In the common language runtime (CLR), the garbage collector (GC) serves as an automatic memory manager. It manages the allocation and release of memory for an application, so developers working with managed code don't have to write code to perform memory management tasks. (S1)

## What it does

- Each time you create a new object, the common language runtime allocates memory for the object from the managed heap. (S2)
- Eventually the garbage collector must perform a collection in order to free some memory. (S2)
- The garbage collector's optimizing engine determines the best time to perform a collection, based upon the allocations being made. (S2)
- It reclaims objects that are no longer being used, clears their memory, and keeps the memory available for future allocations. (S1)
- Managed objects automatically get clean content to start with, so their constructors don't have to initialize every data field. (S1)

## Generations

- The managed heap is divided into three generations, 0, 1, and 2, so it can handle long-lived and short-lived objects separately. (S1)
- Generation 0 is the youngest and contains short-lived objects, such as a temporary variable. (S1)
- Most objects are reclaimed for garbage collection in generation 0 and don't survive to the next generation. (S1)
- Generation 1 contains short-lived objects and serves as a buffer between short-lived objects and long-lived objects. (S1)
- Because objects that survive collections tend to have longer lifetimes, it makes sense to promote them to a higher generation. (S1)

## Claims
- id: C1
  claim: The GC is the CLR's automatic memory manager.
  source: S1
  evidence: "the garbage collector (GC) serves as an automatic memory manager."
- id: C2
  claim: The managed heap has generations 0, 1, and 2.
  source: S1
  evidence: "the managed heap is divided into three generations, 0, 1, and 2"
- id: C3
  claim: Most objects are reclaimed in generation 0.
  source: S1
  evidence: "Objects that survive a generation 0 garbage collection are promoted to generation 1."
- id: C4
  claim: New objects are allocated from the managed heap.
  source: S2
  evidence: "the common language runtime allocates memory for the object from the managed heap."

## Sources
- [S1] Fundamentals of garbage collection - .NET. Microsoft Learn (.NET docs). https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/fundamentals . License: CC BY 4.0 (dotnet/docs). Accessed 2026-11-04.
- [S2] .NET garbage collection - .NET. Microsoft Learn (.NET docs). https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/ . License: CC BY 4.0 (dotnet/docs). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
