Jvm heap size - garbage collection

I´m trying to optimize the jvm heap size for nodes in my cluster. Sadly or good now :slight_smile: First picture is heap size 4GB and second picture is 5GB. Which one looks best for garbage collection?

Personally I think the last picture (5GB) looks best.

Hi @Patrik_Soderstrom,

the first picture looks very untypical for Java applications. It is typically a sign that the heap is almost full and the garbage collector cannot free up a lot of memory. The second picture looks much healthier in that regard.

I just wonder whether the straight line at the top marks the reserved heap size (i.e. 4GB and 5GB respectively) or the total machine memory. I guess it's the latter but if it is the former I think you should investigate that strange behavior.


Hi @danielmitterdorfer,

the line in the top marks the max heap size (reserved).
It sounds and looks like I should increase the heap size from 4 to 5 GB.
What strange behavior do you see on the second picture?

Thanks for taking your time to answer.

Best regards,

Hi @Patrik_Soderstrom,


The behavior as such is fine. But if you consider that the line at the top is 5GB, it looks to me as if CMS (the garbage collector that is used for the old generation) kicks in quite early, at around 50% heap utilization (hard to tell without y-axis labels) but by default it is configured to kick in at 75% heap utilization (as controlled by -XX:CMSInitiatingOccupancyFraction=75). Is it possible that the blue line is actually just showing the size of the old generation instead of total heap utilization? Then this picture would make sense to me.



Now you have the scales and full picture :slight_smile:
The top picture seems to do garbage collection after ~75%.
And the bottom one also seems to be ~75%

So it even might be an idea to increase the 5GB limit to a higher number. I was not aware of the 75% limit. Or would you recommend me setting that limit higher?

Hi @Patrik_Soderstrom,

That helps indeed. I have assumed that the y-axis starts at zero not at 2.8 GB. Everything's fine here and you shouldn't change -XX:CMSInitiatingOccupancyFraction.


1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.