Profile Image
vishnupriya

What is G1 garbage collector: -XX:+UseG1GC?

What is G1 garbage collector: -XX:+UseG1GC? Have you used this JVM argument before? What are the pros & cons of using this Java argument? Can you share your perspective/experience in using this JVM argument?

  • jvm-argument

  • xx-useg1gc

  • x-useg1gc

  • G1 garbage collector

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky

Usage:

 

You can choose 1 of the 5 available garbage collectors, one of them is G1:

 

-XX:+UseG1GC

 

Description:

 

G1 (Garbage First) GC is designed for apps in multi-processor environments with large memory space (more than 4GB). It is available from the JDK7 Update 4. Unlike other collectors, the G1 collector partitions the heap into a set of equal-sized heap regions (usually 1MB to 32MB) chunks, prioritizes them, and then performs the garbage collection on those chunks based on the priority. When G1 performs garbage collections, it shows a concurrent global marking phase (i.e. phase 1, known as Marking) to determine the live and dead objects in the heap. After the marking phase is finished, G1 knows which regions contains most of garbage. These areas cleared first, which usually yields a significant amount of free space. That is why this GC is called Garbage-First.

 

Default Value:

 

Default is Parallel GC.

 

Errors:

 

None

 

Arguments related:

 

TODO link ParallelGCThreads, MaxGCPauseMillis , GCTimeRatio, MinHeapFreeRatio, MaxHeapFreeRatio, Xmx, Xms, UseSerialGC, USeParNewGC, UseParallelGC, UseZGC

 

Related Posts:

 

NOTE:

If you have additional comments, interesting experiences or even point of disagreement with this JVM argument description, please leave a comment. Your insights will help the entire 10+ million java developer community to develop one standard source of documentation for all the JVM arguments.

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • jvm-argument

  • xx-useg1gc

  • x-useg1gc

  • G1 garbage collector