Garbage Collection and Data Structures
Garbage collectors reclaim objects that are no longer reachable from GC roots. Data structures directly influence allocation rate, object graph size, locality, and collection cost. In generational collectors, newly allocated objects typically start in a young generation and surviving objects may be promoted to older generations. Weak references allow a reference to an object without preventing collection when the object is otherwise unreachable.
GC roots include active stacks, static references, and runtime-managed roots.
Gen0/young generation generally contains short-lived allocations.
Surviving objects can be promoted to older generations.
Large or long-lived data structures can increase GC pressure.
Weak references are useful for caches and metadata where retention should not prevent collection.
Exact generation terminology and behavior depend on the runtime and garbage collector.