Different garbage collection algorithms are available:
The default algorithm can be overridden with a different one using the VM option -XX, both for young and old generation.
For example:
-XX:+UseConcMarkSweepGC
Some algorithms cannot work together:
Serial algorithms are designed for single-threaded environments, whereas parallel algorithms are designed for multi-threaded environments.
Most GCs stop or freeze the application, that is stop-the-world. Parallel and serial GCs stop-the-world. Some algorithms like CMS are low-pause, as they stop the application only during some phases. They are more suited for huge heap applications.
The mark and Sweep (MSC) algorithm, first marks reachable objects (mark), then scan the memory for unreachable objects (sweep), finally relocate objects and defragment the memory (compact).
CMS is similar to MSC but multi-threaded. It also differs from parallel GCs as it uses more GPU processing and it suits multi-threaded environment with more than one GPU and affected by GC pauses. However if GPU overhead is crucial, than a parallel GC is best suited.
G1 is the long term replacement for CMS and suits large heap, multi-processor server applications.
Copyright © 2013 Welcome to the website of Davis Fiore. All Rights Reserved.