- Mark clearance: Mark unwanted memory for recycling. Disadvantages: low efficiency, there will be memory fragmentation
- Mark copy: Memory is divided into two equal sized areas, and when one is used up the living objects are copied to the other, clearing the source memory. Disadvantages: Low memory usage
- Tag collation: Marks unwanted memory and removes unwanted memory by moving living objects together.
- Generation algorithm: the heap is divided into new generation and old age. The new generation adopts the tag copy algorithm and the old generation adopts the tag collation algorithm
Mark clear
advantages
Simple implementation, no need for object movement
disadvantages
Low efficiency in marking and clearing, resulting in memory fragmentation and frequent garbage collection
Mark copy
In order to solve the shortcoming of the tag clearing algorithm, a tag copy algorithm is developed
advantages
Simple implementation (no object movement required), high efficiency, no memory fragmentation
disadvantages
Memory usage is low, and objects with high survival rate are frequently replicated
Tag to sort out
Old age objects have a high survival rate, so we cannot use the tag copy algorithm
advantages
Memory fragmentation problem not flagged by cleanup algorithm.
disadvantages
Requires object movement, which is inefficient
Generational collector algorithm
It is divided into new generation, old age and meta-space