023, a step diagram: When that old JVM's garbage collector CMS work, inside and did some what?

This article is a personal learning "from 0 to take you to become a master JVM real" content summary details of the two-dimensional code scanning
    
 
    1, the foregoing review
        After the objects are allocated in the new generation of the Eden area, and then each time garbage collection, live objects have entered Survivor areas, live objects after the next garbage collection will enter another Survivor areas.
    2, the basic principle of CMS garbage collection
        Using markers cleaning algorithm, first by means of tracing GC Roots, to see whether each object is a reference to the GC Roots, and if so, it is survival of the object, or the object is garbage, garbage objects are marked first, then a one-time the objects are recycled garbage out.
    3, if the Stop the World and how garbage collection?
        Cause the system to get stuck for too long, can not handle a lot of response
        So: CMS mode to take the garbage collection system worker threads and threads execute simultaneously try to deal with
    4, CMS how to implement the system while at the same time garbage collection work?        
    1. The initial mark - STW, all GC Roots marked objects directly referenced. quickly. Note: local variables and class methods static variables are GC Roots. But the instance variables are not GC Roots
    2. Concurrent mark - at this stage of the application are executed in parallel, the existing garbage collection thread object GC Roots track, that's all old objects directly associated GC Roots track, rather than through all the years of old objects, understanding where and expressed herein are inconsistent, need further confirmation (author replies: from the beginning tracking GCRoots)
    3. Relabeled - STW, some objects under re-mark the second stage in a newly created, there are some references to existing objects may lose situation becomes garbage. In fact, in the second stage it is to change the system is running off a few objects are marked, so running very fast.
    4. Concurrent cleanup - marked objects to clean out the garbage before, run concurrently with the system program, the system does not affect the program's execution
  
 
 
 
 
The initial mark
STW
All marked objects directly referenced GC Roots
high speed
Concurrent mark
--
Garbage collection thread of existing objects GC Roots track
slow
Relabel
STW
Changes to mark off a few objects
high speed
Concurrent cleanup
--
Clean out spam before marking objects
 
 
 
 
 
 
 
 
Note: local variables and class methods static variables are GC Roots. But the class instance variables are not GC Roots
 
Q: fullgc, the program also runs in parallel to create objects out of that place? You will always trigger fullgc it? If the object is too piled high, waiting for fullgc will complete it? This time it was the world to stop it?
fullgc while usually accompanied by a minorGC, if the first fullGC process, because the reason for the newly created objects has reached the trigger fullGC conditions, above all, will first minorGC, and then try to put the new generation, but also years old at this time no recovery is complete, then trigger a MajorGC does not make sense, because the re-marking will be done this thing.
If after minorGC, the newly created object is still not fit into memory, we need to wait for the end of MajorGC, if still not put into MajorGC end, will the OOM

Guess you like

Origin www.cnblogs.com/csldm/p/11307082.html