3.1.3 Memory structure and GC flow when SerialGC and the explicit memory management functionality are combined
If you select the SerialGC and explicit memory management functionality combined method as the Java memory management method, you can suppress FullGC that occurs in SerialGC by using the explicit memory management functionality. If you select the SerialGC and explicit memory management functionality combined method, specify -XX:+UseSerialGC options, memory options, and other options related to the settings on the explicit memory management functionality and the memory design for the Explicit heap area.
Memory structure when SerialGC and the explicit memory management functionality are combined
The following figure illustrates the memory structure when SerialGC and the explicit memory management functionality are combined as the Java memory management method.
The following table lists the roles of the areas.
No. |
Area name |
Role |
---|---|---|
1 |
Java heap area |
The memory area used by Java programs. The 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 for which GC has been performed at least once and which are in use |
5 |
Tenured area |
The area that stores objects to be used for a long time |
7 |
Explicit heap area |
The area that stores session objects |
6 |
Metaspace area |
The area that stores loaded class information or method information |
8 |
C heap area |
The area used when Developer's Kit for Java executes the native library |
9 |
Thread stack area |
A stack area retained for each thread. |
Memory management mechanism when SerialGC and the explicit memory management functionality are combined
If you select SerialGC as the memory management method, and use the Java heap area, FullGC might occur. To prevent FullGC from occurring, use the explicit memory management functionality to store objects that cause FullGC in the Explicit heap area instead of the Java heap area. Because the objects that cause FullGC are not stored in the Tenured area, which is a FullGC target, you can prevent FullGC from occurring. Note that the objects stored in the Explicit heap area are released explicitly when the object's lifetime ends.
- Objects causing FullGC
-
Objects that have a long lifetime and which become unnecessary after a certain period of time cause FullGC. This applies, for example, to objects relating to session information which is used for a series of processes from login to logout. Because session information is used across multiple requests, it is used for a long time, and will become unnecessary after a certain period of time and when the user logs out. For Application Servers, objects relating to session information are set as objects to be stored in the Explicit heap area by default.
- Memory status when objects become unnecessary
-
The figure below illustrates the memory status when objects with a known lifetime become unnecessary after a specified period of time. Note that the Explicit heap area when the explicit memory management functionality is used consists of memory blocks named explicit memory blocks. Memory in the Explicit area is initialized or released for each explicit memory block.
- When the explicit memory management functionality is used
-
When object group A with a known lifetime in the Explicit heap area becomes unnecessary after a specified period, the explicit memory block where object group A is stored will be deleted.
- When the explicit memory management functionality is not used
-
When object group A with a known lifetime in the Tenured area becomes unnecessary after a specified period, the objects in the group remain in the Tenured area until FullGC occurs.
Parameters to set when SerialGC and the explicit memory management functionality are combined
If you select the SerialGC and explicit memory management functionality combined method as the memory management method, you need to design and tune the memory in the Java heap area and the Explicit heap area. The following figure illustrates the parameters to set when SerialGC and the explicit memory management functionality are combined.
No. |
Item |
Option name |
Description |
---|---|---|---|
1 |
SerialGC settings |
-XX:+UseSerialGC |
Select SerialGC as the memory management method. This parameter is enabled by default. |
2 |
Designing memory |
-Xmxmaximum_Java_heap_area_size |
Set the maximum size of the Java heap area. |
3 |
-Xmsinitial_Java_heap_area_size |
Set the initial size of the Java heap area. For this parameter, we recommend setting the same value as the -Xmx option. |
|
4 |
-XX:MaxMetaspaceSize = maximum_Metaspace_area_size |
Set the maximum size of the Metaspace area. |
|
5 |
-XX:MetaspaceSize=standard_value_for_FullGC_that_originates_from_the_Metaspace_area |
Set the standard value for FullGC that originates from the Metaspace area. FullGC occurs when the Metaspace area size exceeds the standard value, so specify a value estimated from the size of class information required for applications. For this parameter, we recommend setting the same value as the -XX:MaxMetaspaceSize option. |
|
6 |
-XX:CompressedClassSpaceSize = maximum_Compressed_Class_Space_size |
Set the maximum size of the Compressed Class Space area to be created in the Metaspace area when the compressed object pointer functionality is available. For this parameter, we recommend setting the same value as the -XX:MaxMetaspaceSize option. |
|
7 |
-XX:NewRatio = ratio_of_Tenured_area_relative_to_New_area |
Set the ratio of the Tenured area when the New area is assumed to be 1. |
|
8 |
-XX:SurvivorRatio = ratio_of_Eden_area_relative_to_From_space_and_To_space_in_Survivor_area |
Set the ratio of the Eden area when the From and To spaces of the Survivor area are assumed to be 1. |
|
9 |
Explicit memory management functionality settings |
-XX:+HitachiUseExplicitMemory |
Enable the explicit memory management functionality. This parameter is enabled by default. |
10 |
Memory design for the Explicit heap area |
-XX:HitachiExplicitHeapMaxSize = maximum_Explicit_heap_area_size |
Set the maximum size of the Explicit heap area size. |