On CMS GC
Commonly used in old gen GC. New gen uses ParNew
Heap size
- normally 2-6 G, higher than that becomes much more debatable.
- common to set min heap size same as max heap size to reduce OS scheduling cost
Goal: shortest stop the world time.
- tag objects directed referenced by GC roots
- Remark: fix changed introduced during the concurrent tag stage
- By default GC thread 3 = (CPU + 3) /4
- Still need to mark & sweep for old ge
- Old gen will have frag problem that may trigger full gc too much
- New gen GC strategy is same as ParNew
- STW, init mark: mark old gen objects DIRECTLY reachable from the GC root, and old gen objects referred by the new gen.
- Concurrent mark: use GC root tracing to tag all garbages, user thread still running
- Pre-sweep: tag old gen survival objects
- Interruptable pre-sweep
- STW: retag, scan GC roots + new gen + old gen objects with dirty cards
- concurrent sweep: mark unreachable object
- concrrent reset: reset gc state and enter the next GC cycle