A summary of Java garbage collector

Source: Internet
Author: User

1 , a combination of garbage collectors

JAVA a total of garbage collectors 7 , minus those that have not yet been formally used on a large scale G1 , there are 6 One, the Cenozoic 3 One, Laosheng generation 3 A.

Because the garbage collector is a group of work, this 6 Collectors constitute a total of 5

parameter

description

-XX:+USESERIALGC

JVM run the default value in client mode, when this switch is turned on, Memory reclamation using Serial + Serial old collector combination

-XX:+USEPARNEWGC

After this switch is turned on, garbage collection using Parnew + Serial old collector

-XX:+USECONCMARKSWEEPGC

td>

using parnew + CMS +  serial old collector combination for memory recycling, Serial old as a CMS "Concurrent Mode Failure" After the failure of the backup Used by the collector.

-XX:+USEPARALLELGC

JVM run the default value in Server mode, After you turn on this switch, use the parallel scavenge +  serial old collector combination to recycle

-xx:+ USEPARALLELOLDGC

I read Mr. Zhou Zhiming's book "In-depth understanding of JAVA virtual machines", where the 3.4 Chapter Page) has a picture of the garbage collector. The new generation of serial collectors and laosheng generations of CMS collectors, and there is no direct method of invocation, so refer to this piece of content, I re-draw a picture in order to let themselves understand.

2 , garbage collector combination relationship legend

The 6 commonly used Garbage collectors are dispatched and used by these five methods.

3 , part JVM Parameters

some of the other JAVA The parameters of the virtual machine so that it is consulted when needed.

-xx:survivorratio

The capacity ratio of the Eden region to the survivor region in the Cenozoic, the default is 8, which represents eden:subrvivor = 8:1

-xx:pretenuresizethreshold

Directly promoted to the size of the old age object, after setting this parameter, objects larger than this parameter will be allocated directly in the old age

-xx:maxtenuringthreshold

Promotion to the age of the old, each time after minor GC, the age of 1, when the value of this parameter to enter the old age

-xx:useadaptivesizepolicy

Dynamically adjusts the size of each area in the Java heap and the age of entry into the old age

-xx:+handlepromotionfailure

Whether to allow the new generation to collect the guarantee, once minor GC, another piece of survivor space is not enough, will be directly in the old age to retain

-xx:parallelgcthreads

Set the number of threads in a parallel GC for memory reclamation

-xx:gctimeratio

GC time is the column of the total time, the default value is 99, which is to allow 1% GC time, only valid when using the parallel scavenge collector

-xx:maxgcpausemillis

Set maximum pause time for GC, valid under parallel scavenge collector

-xx:cmsinitiatingoccupancyfraction

Set the CMS collector to start garbage collection after the old age space is used, the default value is 68%, only valid in the CMS collector,-xx:cmsinitiatingoccupancyfraction=70

-xx:+usecmscompactatfullcollection

Because the CMS collector is fragmented, this parameter sets whether a memory defragmentation process is required after the garbage collector, only valid when the CMS collector

-xx:+cmsfullgcbeforecompaction

Set up a CMS collector to perform a memory defragmentation process after several garbage collections, usually with the usecmscompactatfullcollection parameter

-xx:+usefastaccessormethods

Original type optimization

-xx:+disableexplicitgc

Whether to turn off manual System.GC

-xx:+cmsparallelremarkenabled

Reduce Mark pauses

-xx:largepagesizeinbytes

The size of the memory page cannot be set too large, affecting the size of the perm,-xx:largepagesizeinbytes=128m



4 , JDK GC some characteristics of the combination method

New Generation GC Mode

Old age and persistent generation GC mode

-xx:+useserialgc

Serial Serial GC

Serial Old serial GC

-xx:+useparallelgc

Parallel Scavenge Parallel Recovery GC

Serial Old serial GC

-xx:+useconcmarksweepgc

Parnew Parallel GC

CMS concurrency GC
When "Concurrent Mode Failure" appears
Using the serial old serial GC

-xx:+useparnewgc

Parnew Parallel GC

Serial Old serial GC

-xx:+useparalleloldgc

Parallel Scavenge Parallel Recovery GC

Parallel Old parallel GC

-xx:+useconcmarksweepgc
-xx:+useparnewgc

Serial Serial GC

CMS concurrency GC
When "Concurrent Mode Failure" appears
Using the serial old serial GC

A summary of Java garbage collector

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.