Garbage collection (GC) is an automatic memory management process that identifies and reclaims memory allocated to objects no longer referenced by the running application. This prevents memory leaks—where unused memory is never freed—and eliminates the need for manual memory deallocation (e.g., free() or delete). Common GC algorithms include tracing collectors (like mark-and-sweep) and reference counting, each with different performance trade-offs regarding pause times and throughput.
