JVM garbage collectors CMS and G1

CMS (Concurrent Mark Sweep) is a collector for the shortest recovery time objectives pause collector. Used the "mark - sweep algorithm", the whole process is divided into four steps

Since the whole process, complicated by concurrent mark and clear, collector threads can work with user threads, so generally speaking, memory recovery process with CMS collector is to be performed concurrently with the user thread. Collector
G1 features:
(1) initial marking CMS initial mark marker object GC Roots can be linked to the Stop The World ---> fast
(2) concurrent mark CMS concurrent mark for GC Roots Tracing
(3) re-marked CMS remark modify the contents of Stop TheWorld concurrent mark due to changes in the user program
(4) concurrent cleared CMS concurrent sweep
Advantages: concurrent collection, low pause
Disadvantages: a large amount of space debris, concurrent phase will reduce throughput
Illustration:
 G1 collector
Features:
Parallel and concurrent generational collection (still retains the concept of generational) spatial integration (as a whole are "mark - finishing" algorithm, does not lead to space debris)
Predictable pause (CMS place more advanced than that allows the user to explicitly specify a length of time segments M milliseconds, consumed in the garbage collection may not exceed N ms)
tempo:
The initial mark (Initial Marking) mark at the object GC Roots can be associated with, and modify the value of TAMS, users need to suspend thread
Concurrent mark (Concurrent Marking) from GC Roots reachability analysis to identify live objects, the user concurrently executing threads
The final mark (Final Marking) as amended in the concurrent marking phase concurrent user program execution result in data changes, users need to suspend thread
Filter Recycling (Live Data Counting and Evacuation) for recovery of the value and cost of each Region to sort, develop recycling programs according to user desired GC pause time 
 
Illustration:
 
 
Compare the difference between CMS and G1 are:
cms generally can be understood: initialize ---> User scene and concurrent execution threads together ---> relabeled ---> concurrent users while cleaning up the thread continues
g1 generally can be understood: the basis of the above can be adjusted cms garbage collection pause times.

Guess you like

Origin www.cnblogs.com/sunxuesong/p/12059524.html