I know that in CMS and G1 heap is divided into Eden, Survivor spaces and Old Generation with only difference that in CMS this division is real (these spaces are contiguous and located in different parts of memory) and in G1 it is logical (the heap is split into ±2000 dynamic regions from 1 to 32 MB each).
In both cases when Eden space is fulfilled threshold Young evacuation starts and the steps are following: Initial marking. STW. Mark the roots of the application. Concurrent marking. From the roots of the links there are transitions to objects from these objects to other objects and thus the achieved objects are marked alive. Remark. STW. Objects created during concurrent marking are also marked live (floating garbage). Cleanup This final phase prepares the ground for the upcoming evacuation phase, counting all the live objects in the heap regions, and sorting these regions by expected GC efficiency.
If the fulfillment of heap reaches the threshold then mixed evacuation (Young + Old) starts in G1. Founding dead objects in Old Generation is based on ‘Remembered Sets’. Each region has a remembered set that lists the references pointing to this region from the outside. These references are regarded as additional GC roots.
After G1 makes a decision which regions from old and young generations to add to collection set.
Why do we need remembered sets and specific search for unreachable objects in Old Generation if we have the entire graph of all objects and know all alive and dead objects after marking them on the Young evacuation level?