Skip to content

Instantly share code, notes, and snippets.

@khotyn
Created December 19, 2011 07:07
Show Gist options
  • Save khotyn/1495819 to your computer and use it in GitHub Desktop.
Save khotyn/1495819 to your computer and use it in GitHub Desktop.
Default CMSInitiatingOccupancyFraction value
java -XX:+UseConcMarkSweepGC -XX:+PrintFlagsFinal Main | grep -P "CMSInitiatingOccupancyFraction|CMSTriggerRatio|MinHeapFreeRatio"
@khotyn
Copy link
Author

khotyn commented Dec 19, 2011

The output of this command in Ubuntu 11.10, JDK 1.6 update 26:

intx CMSInitiatingOccupancyFraction               = -1               {product}           
intx CMSTriggerRatio                                           = 80              {product}           
uintx MinHeapFreeRatio                                      = 40              {product} 

CMSIntiatingOccupancyFraction equals minus one means CMSTriggerRatio is used, and here is CMSTriggerRatio:

Percentage of MinHeapFreeRatio in CMS generation that is allocated before a CMS collection cycle commences.

So, here is how default CMSInitiatingOccupancyFraction calculated: CMSInitiatingOccupancyFraction = (100 - MinHeapFreeRatio) + (CMSTriggerRatio * MinHeapFreeRatio / 100), that is 92%

In book "深入理解Java虚拟机", the arthor says that the default CMSInitiatingOccupancyFraction is 68%, and he is wrong. 68% is the right value in jdk 5 because the CMSTriggerRatio is jdk 5 is default 20%.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment