Mark and sweep
JVM uses the mark and sweep algorithm for garbage collection. Mark and sweep collection consists of two phases.
During the mark phase, all the objects that have live references are marked alive, the rest are presumed candidates for garbage collection. During the sweep phase, the space occupied by the garbage collectable candidates is added to the free list, that is, they are available to be allocated to the new objects.
There are two improvements to mark and sweep. One is concurrent mark and sweep (CMS), and the other is parallel mark and sweep. CMS focuses on lower latency, while the latter focuses on higher throughput. Both strategies have performance trade-offs. CMS does not do compaction, while parallel garbage collector ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access