GC reclaims objects that are no longer reachable from GC roots (thread stacks, static fields, JNI references).
Modern collectors are generational, built on the weak generational hypothesis: most objects die young. New objects are allocated in the young generation's Eden; a minor GC copies survivors between survivor spaces and ages them, and objects that survive enough cycles are promoted (tenured) to the old generation. Collection uses mark-sweep(-compact) or copying algorithms, often with a Stop-The-World pause to walk the object graph, though concurrent collectors do most marking while the app runs.
- Saying GC deletes objects immediately when they are unreferenced.
- Not explaining generations and reachability from GC roots.