Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know region size used of G1 garbage collector?

Tags:

java

g1gc

I'm currently looking into G1 GC in latest Java 8 version.

I have issues with "Humongous Allocation" so I wanna know how big my region size is.

How can I find out how big the region size is set?

How can I calculate the region size myself?

Thanks

like image 588
keiki Avatar asked Oct 17 '17 09:10

keiki


2 Answers

to see the region size, use jinfo -flags your_pid

Non-default VM flags: -XX:G1HeapRegionSize=1048576 -XX:InitialHeapSize=1054867456 -XX:MarkStackSize=4194304 -XX:MaxHeapSize=5368709120 -XX:MaxNewSize=3221225472 -XX:MinHeapDeltaBytes=1048576 -XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseG1GC 
like image 95
roamer Avatar answered Oct 26 '22 23:10

roamer


G1 region-size in Java-8 is based on startingHeapSize/2048 and rounded DOWN to the first power of 2 between 1MB and 32MB; region sizes <1MB or >32MB are not supported.

you can also set the region-size via -XX:G1HeapRegionSize=n (note, the value has the same power-of-2/range restrictions).

so actually the JVM seems biased towards a region count between 2048 and 4095 (assuming a heap between 2GB and 128GB).

in general these are the region-sizes per heap-size range:

 <4GB -  1MB
 <8GB -  2MB
<16GB -  4MB
<32GB -  8MB
<64GB - 16MB
64GB+ - 32MB

note, MB is actually MiB and GB is actually GiB

like image 21
Ron Reynolds Avatar answered Oct 27 '22 00:10

Ron Reynolds