Java Reference
In-Depth Information
CMS uses the MaxGCPauseMllis= N and GCTimeRatio= N settings to determine how large the heap
and the generations should be.
One significant difference in the approach CMS takes is that the young generation is never resized
unless a full GC occurs. Since the goal of CMS is to never have a full collection, this means a
well-tuned CMS application will never resize its young generation.
Concurrent mode failures can be frequent during program startup, as CMS adaptively sizes the
heap and the permgen (or metaspace). It can be a good idea to start CMS with a larger initial heap
size (and larger permgen/metaspace), which is a special case of making the heap larger to prevent
those failures.
If more memory is available, the better solution is to increase the size of the heap. Otherwise,
change the way the background threads operate.
Running the background thread more often
One way to let CMS win the race is to start the concurrent cycle sooner. If the concurrent
cycle starts when 60% of the old generation is filled, CMS has a better chance of finishing
than if the cycle starts when 70% of the old generation is filled. The easiest way to achieve
that is to set both these flags: -XX:CMSInitiatingOccupancyFraction= N and -
XX:+UseCMSInitiatingOccupancyOnly . Using both those flags also makes CMS easier to
understand: if they are both set, then CMS determines when to start the background thread
based only on the percentage of the old generation that is filled. By default, the UseCMSIni-
tiatingOccupancyOnly flag is false , and CMS uses a more complex algorithm to determ-
ine when to start the background thread. If the background thread needs to be started earlier,
better to start it the simplest way possible and set the UseCMSInitiatingOccupancyOnly
flag to true .
Tuning the value of the CMSInitiatingOccupancyFraction may require a few iterations. If
UseCMSInitiatingOccupancyOnly is enabled, then the default value for CMSInitiat-
ingOccupancyFraction is 70: the CMS cycle starts when the old generation is 70% occu-
A better value for that flag for a given application can be found in the GC log by figuring out
when the failed CMS cycle started in the first place. Find the concurrent mode failure in the
Search WWH ::

Custom Search