I'm trying to understand a few things about GC G1 and hope you can guys help me.
- What exactly is the role of whole Concurrent Marking phase in GC G1? I mean all parts (initial marking, root region scan, ..., cleanup).
As far as I understand its role is to mark all live objects reachable from root regions (which in concurrent marking phase are survivor regions selected in 'initial mark' part) and estimate liveness for old regions (base on which they will be selected to collection set for mixed evacuation pause). Am I right?
- Which objects are marked as a garbage in old regions during mixed evacuation pause?
If I understand correctly, mixed evacuation pause marks and remove objects unreachable for GC roots and remembered sets. It's different set of objects that concurrent marking marked so these objects may overlap but they don't have to. Am I right?
What exactly GC roots are? Are they the same for young and mixed collection (except references from remembered sets in mixed collection)?
Is my summary below correct?
Fully young collection marks all live objects (which means that are reachable for GC roots) from eden and survivor regions and evacuate (copy) them to new survivor (or old) regions. Rest of objects are considered as garbage and removed. Free regions are reclaimed.
Concurrent marking phase at the beginning marks all survivor regions which may have references to old regions (base on remembered sets?). Survivor regions are considered here as GC roots because this part takes place during fully young collection so we are sure that all objects in it lives. Then GC goes through objects graph (starting from objects from selected survivor regions) and marks all live objects.
In mixed evacuation pause, base on liveness statistic (counted in the previous phase), some old regions are selected to collection set. Then all live objects from selected regions are evacuated (copied) to new regions (live means: a. selected during concurrent marking and b. as in standard evacuation pause - which are reachable from GC roots and remembered sets). Rest of objects are removed as garbage and regions are reclaimed.