Wins the Offer (GC) - years old garbage collector

The link between the garbage collector , this paper explain old's collector.
Here Insert Picture Description

Serial Old collector (-XX: + UseSerialOldGC, Mark - Collation Algorithm)

Serial GC's version is old, is single-threaded garbage collection must be time to suspend all worker threads, the same is simple and efficient, is the default garbage collector under the Client mode old age.
Here Insert Picture Description

Parallel Old collector (-XX: + UseParallelOldGC, Mark - Collation Algorithm)

JDK6 appeared after the garbage collector, the collector before only Serial Old relatively Serial Old collector is multi-threaded and with throughput priority principle.
Here Insert Picture Description

CMS collector (-XX: + UseConcMarkSweepGC, mark - sweep algorithm)

This garbage collector almost able to work simultaneously and user threads.

Mark - sweep divided into the following steps:

  • Initial labels: STOP-The-World ;
  • Concurrent mark: Concurrent retroactive mark, the program will not stop;
  • Concurrent precleaning: Find objects to perform concurrent marking phase was promoted from the young generation to old age;
  • Relabeled: pause a virtual machine, scanning the remaining target CMS heap ;
  • Concurrent cleaning: cleaning up garbage objects, the program will not stop;
  • Concurrent Reset: reset the data structure CMS collector.
    Here Insert Picture Description
    Mark the beginning of time according to a snapshot of the garbage cleared again, and it will produce a new garbage, and once concurrent user threads refresh perform, the drawback is the use of mark - sweep algorithm will produce memory fragmentation, there is a risk OOM.

G1 collector (-XX: + UseG1GC, copy + mark - Collation Algorithm)

This garbage collector is suitable for the old and the new generation's, and other old's garbage collector has the following characteristics compared:

  • Parallel and Concurrent : a plurality of CPU used to reduce stop-the-world stop time, multithreaded executed concurrently;
  • Generational collection : use different ways to deal with newly created objects out of the garbage and waste generation for some time objects produced;
  • Spatial Integration : By tags to organize to solve the problem of memory fragmentation;
  • Predictable pause : the user designate time consumed on the GC, no more than a set time.

After using this garbage collector entire Java heap memory is divided into a plurality of equal size Region, the old and the new generation's not physically isolated.
Here Insert Picture Description
You do not need a contiguous memory space which is to decide which is the new generation of the old era.

Published 219 original articles · won praise 21 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_44240370/article/details/104074883