I am confused about two parameters that may control when the CMS collector kicks in:
MaxHeapFreeRatio (70% by default)
CMSInitiatingOccupancyFraction (over 90% by default)
What does each of those parameters mean, exactly? When does the collector start (the marking phase), and collect (the sweeping phase)?
CMSInitiatingOccupancyFractiondecides when the CMS kicks in (in order for this option to be effective you must also set-XX:+UseCMSInitiatingOccupancyOnly).MaxHeapFreeRatiois an option to size the generational spaces.See for example …
http://java.sun.com/docs/hotspot/gc1.4.2/faq.html
http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html
.. or ..
http://www.petefreitag.com/articles/gctuning/
EDIT : I ran a few simulations with a test program that just randomly creates maps of byte arrays and copies them around. I noticed that a) fraction value was not respected – in particular with a conservative value (say 50) the CMS initial mark stage kicked in much beyond 50% occupancy, typically around 70-80% and b) nonetheless smaller fraction values made the CMS initial stage happen earlier
(program used
-Xmx1536m -Xmx1536m -XX:NewSize=512m -XX:+UseConcMarkSweepGc+ gc logging and the two test parameters)I’ve also found an old bug report regarding this: https://bugs.java.com/bugdatabase/view_bug?bug_id=6486089