Search code examples
javag1gc

Does G1 garbage collector use the same region size for every region?


Oracle's Getting Started with the G1 Garbage Collector tutorial says the following about region sizes with the G1 garbage collector:

The heap is one memory area split into many fixed sized regions.

[...]

Region size is chosen by the JVM at startup. The JVM generally targets around 2000 regions varying in size from 1 to 32Mb.

It's not clear for whether all region has the same size in a JVM or there could be regions with different sizes (for example, 1500 regions with size of 1MB and 500 regions with size of 2MB).


Solution

  • Yes, the regions are of the equal size. The article Garbage First Garbage Collector Tuning says:

    The G1 GC is a regionalized and generational garbage collector, which means that the Java object heap (heap) is divided into a number of equally sized regions.

    The JVM aims to create about 2000 regions. Their acutal sizes depend on your minimum heap size.