First Mark all cleanable memory, then Clean at one time
- Efficiency problem
- Memory fragmentation
Use when surviving rate is low(Usually it is the case)
- Divide the entire memory into 2 sections
- Use only one of the section as memory allocation section.
- Once that allocation section is exhausted, move the part that are still being used onto the top of the other memory section
- Cleaning the allocation section.
In this way, there is no memory fragmentation, and cleaning is quite efficient. Major commercial JVM use this strategy
- Memory usability is 50% only
Use when surviving rate is high.
- Just like
compactthe memory. Move the memory into one direct so that there is no memory fragment
Major commercial JVM use this strategy. Must use along with other strategy.
Must stop all the other works when collecting, which is so bad.
Multi-thread version of
Serial collector, nothing new.
Similar to ParNew but this collector focuses on reaching a controllable throughout.
Sometimes also called
Throughout first collector
Concurrent Mark Sweep
To collect as fast as possible.
- Init mark(Stop the world)(Only mark objects that are directly GC related)
- Concurrent mark(GC Roots tracing)
- Remark(Stop the world)(Check objects that changed during concurrent mark)
- Concurrent sweep
Great collector. Sensitive to CPU
Art of the state collector.
Maintain a priority queue of garbage, collect the garbage first to ensure good throughout.