uCosminexus Application Server, Expansion Guide

[Contents][Index][Back][Next]

8.2.2 Mechanism of inhibiting full garbage collection 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, which is out of the Java heap, and is not targeted for garbage collection. If you are not using the Explicit Memory Management functionality, you can inhibit the occurrence of a full garbage collection by placing the Java objects, which were earlier placed in the Java heap, in the Explicit heap.

This subsection describes the mechanism of inhibiting the full garbage collection by using the Explicit Memory Management functionality and also the positioning of the Explicit Memory Management functionality.

Organization of this subsection
(1) Mechanism of inhibiting full garbage collection
(2) Positioning of the Explicit Memory Management functionality
(3) Required memory size when using the Explicit Memory Management functionality

(1) Mechanism of inhibiting full garbage collection

If the Eden area runs out of free space during the execution of a Java application, a garbage collection occurs. In such a case, JavaVM executes full garbage collection, if the following formula is satisfied.

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

#
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 formula shows, the full garbage collection occurs if the size of the free space in the Tenured area becomes less than the size of the memory that is used in the New area. The free space in the Tenured area is used by Java objects that move (rise) from the Survivor area when the copy garbage collection occurs. In other words, if you can reduce the rising Java objects, you can inhibit the occurrence of the full garbage collection. The objects that are not deleted during multiple executions of the copy garbage collection and that are targeted for rising are called long-life objects.

The long-life objects are broadly categorized into two types. One type of the objects is the objects that are not recovered by a full garbage collection. For example, the objects that should essentially be stored in the Tenured area, and which continue to exist constantly during the application execution. Such objects are not the real cause of a full garbage collection because they do not continue to increase. If you want to eliminate the impact of such long-life objects, increase the size of the Tenured area.

Another type of the objects is the objects that are recovered by a full garbage collection. The long-life objects that are recovered by the full garbage collection are the objects that have a long-life to the extent of rising in the Tenured area, but become unnecessary over a certain period of time. Such long-life objects cause a full garbage collection because they continue to increase until the full garbage collection occurs.

The following figure shows the objects that are recovered by the full garbage collection and the objects that are not recovered by the full garbage collection.

Figure 8-1 Objects that are recovered by full garbage collection and the objects that are not recovered by full garbage collection

[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. Even if you double the size of the Tenured area, the interval of occurrence of full garbage collection is doubled and you cannot achieve the expected result.

In other words, decreasing the rise of objects, which will become unnecessary over a certain period of time, to the Tenured area is the key to inhibit the occurrence of a full garbage collection.

On Application Server, the rise destination for the copy garbage collection of some Java objects is set to the Explicit heap. The following figure shows the difference between rise when you are not using the Explicit Memory Management functionality and when you are using the Explicit Memory Management functionality.

Figure 8-2 Difference between rise 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 rise, 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 8.4 When using a J2EE server objects placed in the Explicit heap. For details on the algorithm of garbage collection, see 7. Memory Tuning of JavaVM 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 8.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 8-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 object that is referenced from objects placed in the Explicit management Heap by using automatic placement functionality, is automatically moved to the Explicit management heap on the basis of a reference relation when a garbage collection occurs. 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
  • Placement of objects to the Explicit heap by changing the allocation processing integrated with a garbage collection
    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 Functionality of statistics of unnecessary objects in Tenured area in the uCosminexus Application Server Maintenance and Migration Guide.

Explicit heap
The Explicit heap is an area where the Java objects that are not targeted for garbage collection are placed and 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.10 Explicit heap tuning in the uCosminexus Application Server System Design Guide.