javagarbage-collectionjvm-hotspotg1gc

How to determine region size automatically generated by g1gc?


Documentation says that:

Upon startup, the Java Virtual Machine (JVM) sets the region size

How could I determine what size was chosen for g1gc regions at the startup? How to get notification when it is changed during runtime?

I had tried to log gc info with -XX:+PrintGCDetails but it contains no information about region size.


Solution

  • The region size information can be printed with the -XX:G1PrintRegionLivenessInfo flag which must be used in conjunction with the -XX:+UnlockDiagnosticVMOptions flag (well, at least used to, not sure about the latest JVMs).

    See also this article in the Oracle blog and this very insightful article from Hubspot (simply search for "Min Heap Size").