Hitachi

Hitachi Application Server V10 User's Guide (For UNIX® Systems)


3.1.4 Memory structure and GC flow for G1GC

When G1GC is selected as the Java memory management method, three types of GCs including YoungGC, MixedGC, and FullGC occur for the memory areas. For YoungGC and MixedGC, you can control when to stop applications when GC occurs. To select G1GC, specify the -XX:+UseG1GC option, the target time for stopping applications when GC occurs, the options related to Java heap, and the options for tuning processing performance.

Memory structure for G1GC

The following figure illustrates the memory structure when G1GC is selected as the memory management method of Java.

[Figure]

The following table shows the roles of each area.

No.

Area name

Role

1

Java heap area

The memory area used by Java programs. This area is divided into the New area and the Tenured area.

2

New area

The area that stores new objects. This area is divided into the Eden area and the Survivor area.

3

Eden area

The area that stores objects immediately after they are created

4

Survivor area

The area that stores objects that are in use and for which GC has been performed at least once

5

Tenured area

The area that stores objects to be used for a long time

6

Metaspace area

The area that stores loaded class information and method information

7

C heap area

The area used when Developer's Kit for Java executes the native library

8

Thread stack area

A stack area that is retained for each thread

9

Not allocated area in the New area

An area in the New area. This area is not allocated to the Eden or Survivor area.

10

Humongous area

The area that stores large objects. Part of the Survivor area and continuous regions are allocated.

11

Not allocated area

An area in the Java heap area. This area is not allocated to any other area.

GC flow for G1GC

G1GC manages the Java heap area for each memory block (called a region). For this reason, it does not reserve the New area or the Tenured area as a continuous area. Objects are stored in regions. If there is no available space in a region, G1GC allocates a region which is not currently allocated to the area, and then stores objects there.

The following figure illustrates the GC flow when G1GC is selected as the memory management method.

[Figure]

  1. YoungGC

    YoungGC occurs when there is no more space in a region allocated to the New area. When this occurs, objects in use are moved to the region allocated to the Survivor area, and objects which are no longer used are released for each region. In addition, each time YoungGC occurs, the objects in use are moved across the regions allocated to the Survivor area. When the number of moves reaches a specified number, the objects move to a region allocated to the Tenured area. After YoungGC occurs, G1GC estimates the time required for the next GC based on the time spent for the current GC, and then changes the size of the New area. The figure after YoungGC is an example of the New area being decreased due to the GC taking more time than expected.

  2. MixedGC

    MixedGC occurs when the usage rate of the Tenured area increases. When this occurs, the GC target is the regions allocated to the New area and the regions allocated to part of the Tenured area within the target down time. Based on analysis information about whether the objects that are executed in parallel to applications are in use, these regions allocated to the Tenured region become the GC target in order of the region for which the size of the region to be released is the largest. For this reason, if the analysis of object information is insufficient or the analysis results indicate that MixedGC has little effect, MixedGC does not occur.

  3. FullGC

    FullGC occurs for the entire Java heap area, when there is no more space in a region in the heap area and MixedGC does not occur.

Parameters to set for G1GC

To select G1GC as the memory management method, you need to design and tune the memory so that the application down time and the throughput by GC meet the system requirements. Note that G1GC cannot control application down time triggered by FullGC. For this reason, when FullGC occurs, you need to tune the memory to prevent FullGC from occurring. The following figure shows the parameters to be set for G1GC.

No.

Item

Option name

Description

1

G1GC settings

-XX:+UseG1GC

Selects G1GC as the memory management method.

2

-XX:MaxGCPauseMillis = target_down_time

Sets the target down time in milliseconds.

3

Designing the memory

-Xmxmaximum_Java_heap_area_size

Sets the maximum size for the Java heap area.

4

-Xmsinitial_Java_heap_area_size

Sets the initial size for the Java area. We recommend that you set the same value for this parameter as the -Xmx option.

5

-XX:MaxMetaspaceSize = maximum_Metaspace_area_size

Sets the maximum size for the Metaspace area.

6

-XX:MetaspaceSize = initial_Metaspace_area_size

Set the standard value for FullGC that results from the Metaspace area. This value must be designed in the same manner as the initial size because the Metaspace area will be expanded if the Metaspace area size exceeds the standard value. We recommend that you set the same value for this parameter as the -XX:MaxMetaspaceSize option

7

-XX:CompressedClassSpaceSize = initial_Compressed_Class_Space_area_size

Sets the size of the Compressed Class Space area to be created in the Metaspace area when the compressed object pointer functionality is enabled. Specify the same value as the -XX:MaxMetaspaceSize option.

8

-XX:SurvivorRatio = ratio_for_maximum_Survivor_area_size_for_New_area

Sets the ratio when the size of the Survivor area is at its maximum for the New area.

9

Tuning processing performance

-XX:ParallelGCThreads = number_of_threads_for_YoungGC_and_MixedGC

Sets the number of threads where YoungGC and MixedGC are performed. Set this value according to the number of threads for ConcGCThreads.

10

-XX:ConcGCThreads =number_of_threads_where_processing_is_performed_in_parallel_to_applications

Sets the number of threads to be processed in parallel with application.