Back to course

Garbage Collection

C# Zero to Hero: Comprehensive Programming Masterclass

The Garbage Collector (GC)

The GC automatically manages the memory for your application. It frees memory occupied by objects that are no longer being used.

Generations

  • Gen 0: Short-lived objects.
  • Gen 1: Buffer between short and long-lived.
  • Gen 2: Long-lived objects.