G1 collector

This is the new collector, introduced in JDK 7 update 4. The G1 collector is designed for an application willing to allocate heap memory of more than 4 GB. G1 divides the heap into multiple regions, spanning from 1 MB to 32 MB, depending on the heap we configure and uses multiple background threads to scan through the heap regions. The benefit of dividing the heap into multiple regions is that G1 will scan through regions where there is plenty of garbage first in order to meet a given pause time.

G1 reduces the change of low-heap availability before the background threads have finished scanning for unused objects. This reduced the chances to STW. G1 compacts the heap on-the-go, unlike CMS, which does this during STW.

In order to enable the G1 garbage collector in our application, we need to set the -XX:+UseG1GC option in the JVM parameters.

Java 8 update 20 introduced a new JVM argument, -XX:+UseStringDeduplication, for the G1 collector. With this argument, G1 identifies duplicate strings and creates the pointer to the same integral char[] array to avoid multiple copies of the same string.
From Java 8 PermGen, part of the heap is removed. This was the part that was allocated for class metadata, static variables, and interned strings. This parameter-tuning caused many OutOfMemory exceptions, which would be fine from Java 8 onward, where JVM would take care of it.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset