.Net achieves automatic cleanup with the Garbage Collector (GC). All the GC does is look for allocated objects on the heap that aren’t being referenced by anything. The most obvious source of references, as we saw earlier, is the stack. Other potential sources include:

  • Global/Static object references
  • CPU registers
  • Object Finalization references (more later)
  • Interop references (.NET objects passed to COM/API calls)
  • Stack references

Collectively, these are all called root references or GC Roots.