tuan long tuan long - 1 month ago 12
Java Question

Does java young gc pause time affect by remained garbage size of survivor space

I get a deep interest in java gc in these days. I want to get young gc optimized cause some of the stw is really annoying. After many times of testing I find the young gc pause time greatly affected by the size of remained live data in survivor space like (printed by jstat -gcnew):
enter image description here

Can anyone tell me it is right or not and why. Thanks a lot.


most JVMs use a semi-space collector for the young generation. Which means all the surviving young gen objects have to be copied, dead objects do not. So the time spent copying directly relates to the live data while the generation size itself is only indirectly related simply because size * mortality and old promotion rates dictates how much live objects can reside in the young gen.

greatly affected by the size of remained garbage

if it's remaining after a collection then it's likely to be live data, not garbage.