The problem is like this.
We are using CMS and experiencing concurrent mode failure (takes about 15 seconds). Using JRE 8.
Already using UseCMSInitiatingOccupancyOnly and CMSInitiatingOccupancyFraction (80%). Not using CMSScavengeBeforeRemark.
The allocation pattern is like this:
Lots of short-lived objects are allocated. So we are using a large young generation, 2GB. Survivor space not tuned. MaxTenuringThreshold set to 15. Every a few hours CMS kicks in.
Old generation is 4GB. Memory usage is high. After each collection, the old generation has about 30% free space. Unfortunately no more memory available. We are planning to modify the program to make it use less memory, but this takes time.
Usually the program doesn't have much work to do, but every a few hours (we can't predict when) we get really busy. And a 15-second STW is just too long.
So my question is:
How can we tune CMS for our program?
Should I increase old generation (and decrease young)?
Should I adjust Survivor?
Should I change CMSInitiatingOccupancyFraction?
Will G1GC help?
Old generation is 4GB. experiencing concurrent mode failure (takes about 15 seconds).
That is not exactly a large heap. If you're experiencing concurrent mode failures which are single-threaded you might as well use the parallel collector for that size.
So we are using a large young generation, 2GB.
This is comparatively huge, given the overall heap size of 4GB, you should shrink the young generation so that the old gen has more than those 30% breathing room.
Every a few hours CMS kicks in.
Then you could afford to run that more frequently by decreasing the IHOP