Profile Image
vishnupriya

What is JVM startup parameter: -XX:CMSExpAvgFactor?

What is JVM startup parameter: -XX:CMSExpAvgFactor? 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-cmsexpavgfactor

  • x-cmsexpavgfactor

  • JVM startup parameter

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky

Usage:


 This flag allows you to set a percentage of time to weight the exponentially averaged samples of concurrent recycling statistics. Its syntax is the following;-XX:CMSExpAvgFactor=precent, where percent is the percentage that should be inside of the range of 0 and 100.

 

Since:

 

Starting from JDK 6.

 

Deprecated:

 

Obsoleted in JDK 14.

 

Expired in JDK 15.

 

Examples:

 

This command will set a factor to 50%:

 

java -XX:CMSExpAvgFactor=50 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.

 

That being said, JDK exposed some arguments to allow you to manage and control CMS. One of them is our main topic which is “CMSExpAvgFactor” which allows you to set a percentage of time that’s being used to measure the current sample when calculating CMS statistics.

 

Default Value:

 

The default value is 25.

 

Default Value:

 

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

 

Arguments related:

 

CMSInitiatingOccupancyFraction, CMSScavengeBeforeRemark, CMSClassUnloadingEnabled, CMSScavengeBeforeRemark, CMSIncrementalSafetyFactor, UseCMSInitiatingOccupancyOnly, CMSPermGenSweepingEnabled, UseConcMarkSweepGC, CMSIncrementalMode, CMSIncrementalDutyCycle, CMSIncrementalDutySafetyFactor, CMSIncrementalOffset, CMSIncrementalPacing, CMSTriggerRatio 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-cmsexpavgfactor

  • x-cmsexpavgfactor

  • JVM startup parameter