Hitachi

uCosminexus Application Server Expansion Guide


7.2.2 Mechanism of suppressing Full GC by using the Explicit Memory Management functionality

The Explicit Memory Management functionality uses an independent area called the Explicit heap as the Java object placement destination. The Explicit heap is an area outside the Java heap that is not subject to GC. Java objects in the Java heap can trigger GC. If the Explicit Memory Management functionality is used, these Java objects are moved to the Explicit heap. As a result, Full GC for those Java objects is suppressed.

This section describes the mechanism whereby Full GC is suppressed by using the Explicit Memory Management functionality. This section also describes the role of the functionality.

Organization of this subsection

(1) Mechanism of suppressing Full GC

If the Eden area runs out of free space while a Java application is running, GC occurs. At this time, Java VM performs Full GC if the following expression is satisfied:

Size of memory that is used in New area > Size of free space in Tenured area
Note

Because the Eden area is out of free space, the size of the memory used in the New area is almost the same as the maximum size of the New area.

As the preceding expression shows, Full GC occurs when the free space in the Tenured area becomes low. The free space in the Tenured area is consumed by Java objects that are moved (promoted) from the Survivor area when copy GC occurs. Therefore, occurrence of Full GC can be suppressed by decreasing the number of Java objects that are promoted. Note that objects that survive copy GC several times without being deleted and get promoted to the Tenured area are called long-life objects.

The long-life objects are broadly categorized into two types. Long-life objects of one type are those that are not reclaimed by Full GC. For example, the objects that should essentially be stored in the Tenured area, and which continue to exist constantly during the application execution. Because these objects do not increase continuously, they are not an essential cause of Full GC occurrence. If you want to eliminate the impact of such long-life objects, increase the size of the Tenured area.

Long-life objects of the other type are those that are reclaimed by Full GC. These objects have life that is long enough to the extent that they are promoted to the Tenured area but become unnecessary in a certain period of time. Because such long-life objects continue to increase until Full GC occurs, they can be a cause of Full GC occurrence.

The following figure shows objects that are reclaimed and are not reclaimed by Full GC.

Figure 7‒1: Objects that are reclaimed and are not reclaimed by Full GC

[Figure]

You cannot prevent the increase of objects, which will become unnecessary over a period of time only by increasing the size of the Tenured area. For example, if you double the size of the Tenured area, the Full GC occurrence interval will only be doubled. The effect gained will be less than expected.

Therefore, to suppress occurrence of Full GC, it is important to reduce the number of objects that are promoted to the Tenured area but become unnecessary in a certain period of time.

On the application server, settings are specified so that some Java objects are promoted to the Explicit heap when copy GC occurs. The following figure shows the difference in promotion when you are not using the Explicit Memory Management functionality and when you are using the Explicit Memory Management functionality.

Figure 7‒2: Difference in promotion when you are not using Explicit Memory Management functionality and when you are using Explicit Memory Management functionality

[Figure]

In both the cases, status is same at step 1. In step 2, when the objects are promoted, all long-life objects are moved to the Tenured area if you are not using the Explicit Memory Management functionality. On the other hand, if you are using the Explicit Memory Management functionality, the objects from among the long-life objects that will definitely be destroyed after a certain period of time, are moved to the Explicit heap. Thus, only the long-life objects, which are not planned to be destroyed, are moved to the Tenured area and the used size of the Tenured area increases slowly. As shown in step 3, if you are using the Explicit Memory Management functionality, objects in the Explicit heap are deleted when they become unnecessary.

For details on the target Java objects, see 7.4 When using J2EE server objects placed in Explicit heap. For details about GC algorithms, see 7. JavaVM Memory Tuning in the uCosminexus Application Server System Design Guide.

If you use the Explicit Memory Management functionality in an application developed that you have developed, generate long-life objects, which will be destroyed over a certain period of time, directly in the Explicit heap. That will prevent an increase in the memory size of the Tenured area. For details on the Java objects that can be generated in the Explicit heap, see 7.5 Objects that you can optionally place in the Explicit heap in the application.

(2) Positioning of the Explicit Memory Management functionality

The Explicit Memory Management functionality is a functionality of JavaVM. You can use the Explicit Memory Management functionality in the following two ways:

The following figure shows the positioning of the Explicit Memory Management functionality. Note that the JavaVM log file output functionality in the figure refers to JavaVM log file output functionality.

Figure 7‒3: Positioning of the Explicit Memory Management functionality

[Figure]

This subsection describes the Explicit Memory Management functionality API, automatic placement configuration file, configuration file for the Explicit Memory Management functionality application exclusion or disabling application exclusion, functionality for configuring the Explicit Memory Management functionality, functionality of statistics of unnecessary objects in the Tenured area, and the Explicit heap.

Explicit Memory Management functionality API

If you want to use the Explicit Memory Management functionality from a Java program, use the Explicit Memory Management functionality API. With this API, you can execute the operations related to the Explicit heap. You can also collect the use status of the Explicit heap as statistics.

Automatic placement configuration file

Use the automatic placement configuration file to use the Explicit Memory Management functionality without making changes to the Java program. Specify the objects that you want to place in the explicit management heap, in the file.

Configuration file for Explicit Memory Management functionality application exclusion or disabling application exclusion

The objects referenced by objects that have been automatically moved (by using the automatic placement functionality) to the Explicit management heap are also automatically moved to the Explicit management heap when GC occurs based on a reference relation. If you want to exclude the objects to be moved on the basis of this reference relation, from an application of the Explicit Memory Management functionality in the unit of class, use the configuration file for the Explicit Memory Management functionality application exclusion and configuration file for disabling application exclusion of the Explicit Memory Management functionality.

When you want to exclude an object from an application target of the Explicit Memory Management functionality, use the configuration file for the Explicit Memory Management functionality application exclusion. Specify classes of the objects, which are not to be moved to the Explicit management heap, in this file.

In cases such as when all classes in the same package are excluded from an application target of the Explicit Memory Management functionality in the configuration file for the Explicit Memory Management functionality application exclusion, if you want to target some classes for application of the Explicit Memory Management functionality, use the configuration file for disabling application exclusion of the Explicit Memory Management functionality. Specify the classes, for which the setting of application exclusion of the Explicit Memory Management functionality is to be disabled, in this file.

Functionality for configuring the Explicit Memory Management functionality

Any functionality that configures the Explicit Memory Management functionality is included in JavaVM. Such functionality is called by API. You can execute the following processes:

  • Management and control of the Explicit heap and memory blocks in the heap

  • Moving of objects to the Explicit heap by changing the allocation processing linked with GC

    The allocation process is executed by the extension of a new keyword.

  • Control on movement of objects to Explicit heap memory blocks

  • Output of an Explicit heap event log and the status to JavaVM log file and the thread dump

Functionality of statistics of unnecessary objects in the Tenured area

This functionality checks the unnecessary objects that are the cause of memory increase in the Tenured area. For details on the functionality of statistics of unnecessary objects in Tenured area, see 9.8 Unused objects statistical functionality in the Tenured area in the uCosminexus Application Server Maintenance and Migration Guide.

Explicit heap

Java objects not subject to GC are moved to this area. This area is managed by the Explicit Memory Management functionality. The Explicit heap is configured from multiple memory blocks (Explicit memory blocks).

(3) Required memory size when using the Explicit Memory Management functionality

The Explicit heap managed by the Explicit Memory Management functionality is an area outside the Java heap. When using an Explicit heap, the memory usage increases as compared to memory usage when not using the Explicit heap.

When using the Explicit Memory Management functionality, you need to estimate and appropriately set the maximum size of the Explicit heap as the required memory size. For details on the flow of using the Explicit Memory Management functionality, objects stored in the Explicit heap (objects that are the cause of memory size increase in the Tenured area), and the estimation of the Explicit heap size, see 7.11 Explicit heap tuning in the uCosminexus Application Server System Design Guide.