JVM garbage collector and its optimization

Garbage collector and GC optimization parameters

Young GenerationSerial    ParNew   ParallelScavenge

Tenured GenerationCMS     Parallel Old    Serial Old(MSC)

other  G1

Serial

Features: Cenozoic single-threaded STW can cooperate with CMS replication algorithm

Applicable to Client mode with fewer CPUs

 

ParNew

Features: Cenozoic multi-threaded STW can cooperate with CMS replication algorithm

It is suitable for Server mode with multiple CPUs , but it may not perform as well as the Serial collector under four cores .

 

Parallel Scavenge

Features: Adaptive adjustment strategy throughput control STW new generation multi-threaded replication algorithm

* Throughput is the proportion of the total time of running user code.      Total time = user code time + GC consumption time

Suitable for environments with a high proportion of background operations

 

Serial Old

Features: Old age single-threaded mark - tidying algorithm CMS backing collector

Applicable to Client mode with fewer CPUs

 

 

Parallel Old

Features: Multi-threaded mark - sorting algorithm throughput control

Suitable for environments where CPU resource allocation is tight and throughput needs to be controlled

 

CMS

Features: fast response mark - sweep algorithm multi-threaded concurrent work

* Because the garbage collection is performed concurrently with the user thread, the old age data generated during collection cannot be recycled, and it cannot be recycled when the old age is fully loaded. It needs to be recycled in advance to reserve a certain space for the user thread.

* If the memory allocated by the old generation is insufficient or the threshold is set too low, the collection threshold may be frequently hit, resulting in performance degradation

* If the space required by the user thread is insufficient, it will cause ConcurrentMode Failure , thus switching to the backup collector Serial Old

Suitable for environments with multiple CPUs and enough memory

 

G1

Features: Concurrency + parallel work predictable collection time model retains the concept of generational efficient

Suitable for multi- CPU environments

 

Choose a garbage collector:

UseSerialGC    uses Serial+Serial Old / Client mode by default

UseParNewGCUse    ParNew +SerialOld

UseConcMarkSweepGC   uses ParNew+CMS+Serial Old ( as CMS backup )

UseParallelGC     使用Parallel Scavenge + Serial Old(PS MarkSweep)

UseParallelOldGC     使用Parallel Scavenge + Parallel Old

 

Unstable optimization parameters:

The ratio of Eden to Survivor     in the new generation of SurvivorRatio

Objects whose space occupied by PretenureSizeThreshold      is larger than this parameter enter the old age directly

MaxTenuringThreshold    sets the age limit for promoting the old generation / Minor GC age in each new generation +1

UseAdaptiveSizePolicy   with auto-sizing policy /Parallel Scavenge is effective

Does HandlePromotionFailure      allow guaranteed allocation failures

ParallelGCThreads    sets the number of threads for ParallelGC

GCTimeRatio The ratio of GC to total time / Parallel Scavenge effective   default 99

MaxGCPauseMillis GC maximum pause time / Parallel Scavenge valid

CMSInitiatingOccupancyFraction    Old age collection threshold / CMS valid

UseCMSCompactAtFullCollection     does one defrag /CMS work after garbage collection is done

CMSFullGCsBeforeCompaction     One defragmentation after several garbage collections / CMS is valid

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325659346&siteId=291194637