Garbage collection is the process of identifying used and unused objects in heap memory and deleting the unused objects. It involves marking referenced and unreferenced objects, then deleting unreferenced objects using normal deletion or compaction. Generational garbage collection focuses on young, old, and permanent generation objects, allocating to Eden space and copying/promoting referenced objects to older generations as they age over time.