Garbage collection is the process of identifying and deleting unused objects in heap memory. It involves marking reachable objects, deleting unreachable objects, and optionally compacting memory. The developer can choose between several garbage collector algorithms like serial, parallel, concurrent mark sweep, and garbage first in OpenJDK. By default Java 8 uses parallel collection while Java 9 will change the default to garbage first.