Profile Image
vishnupriya

What is JVM startup parameter: -XX:CMSTriggerRatio?

What is JVM startup parameter: -XX:CMSTriggerRatio? Have you used this JVM arguement before? What are the pros & cons of using this Java argument? Can you share your perspective/experience in using this JVM argument?

  • jvmargument

  • xx-cmstriggerratio

  • x-cmstriggerratio

  • JVM startup parameter

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky

Usage:


 This flag set a percentage of “MinHeapFreeRatio” in Concurrent Mark Sweep (CMS) generation that is allocated prior to a starting of a CMS cycle. It has the following syntax:-XX:CMSTriggerRatio=ratio, where ratio is the percentage of “MinHeapFreeRatio” and it should be between 0 and 100

Since:

 

Starting from JDK 6.

 

Since:

 

Obsoleted in JDK 14.

 

Expired in JDK 15.

 

Examples:

 

This is an example to set an occupancy rate of 80%:

 

java -XX:CMSTriggerRatio=80 MainClass

 

Description:

 

Before talking about the flag, we need to introduce Garbage Collector (GC) and Concurrent Mark Sweep (CMS):

 

Garbage Collector is a way of the JVM to clean the memory and makes the java memory more efficient. It tracks (Mark step) and removes (sweep step) every unused object available in the JVM heap space. An object is considered unused when it’s referenced by null, assigned to another reference or by anonymous object …. There are 5 type of GC implementations:

 

  • Serial Garbage Collector
  • Parallel Garbage Collector
  • CMS Garbage Collector
  • G1 Garbage Collector
  • Z Garbage Collector

 

CMS Garbage Collector, as mentioned above, is one of the implementations of GC, which uses multiple thread for garbage collection. It’s created for applications that favor shorter garbage collection pauses and that can afford to share processor resources with the garbage collector while the application is running. It achieves long pauses by two ways:

 

  • By using free lists to manage reclaimed space instead of compacting the Old Generation.
  • By doing mainly the job in Mark (marking a reference) and Sweep (removing the marked reference) process simultaneously with the application. Which means that the GC is not stopping or freezing the application’s threads to do its job. But it does take part of using the CPU time with the application. By default, GC algorithm can use number of threads up to ¼ of the number of physical cores of your machine.

 

Hence, the concurrent garbage collector has multiple arguments to manage it the way you want to, one of them is “CMSTriggerRatio” which allows you to set a percentage of the value set by the flag “XX:MinHeapFreeRatio” in a Concurrent Mark Sweep (CMS) generation that is allocated prior to a starting of a CMS cycle.

 

Default Value:

 

The default value is 80.

 

Error:

 

An exception is thrown when the value used is outside of the range 0 and 100.

 

Arguments related:

 

CMSInitiatingOccupancyFraction, CMSScavengeBeforeRemark, CMSClassUnloadingEnabled, CMSScavengeBeforeRemark, CMSIncrementalSafetyFactor, UseCMSInitiatingOccupancyOnly, CMSPermGenSweepingEnabled, UseConcMarkSweepGC, CMSIncrementalMode, CMSIncrementalDutyCycle, CMSIncrementalDutySafetyFactor, CMSIncrementalOffset, CMSIncrementalPacing and CMSIncrementalDutyCycleMin

 

Related Posts:

 

 

 

 

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • jvmargument

  • xx-cmstriggerratio

  • x-cmstriggerratio

  • JVM startup parameter