7.6.5 Moving the objects from the Java heap to the Explicit memory block based on a reference relation
When objects move from the Java heap to the Explicit memory block, the objects in the Java heap that are being referenced from objects in the Explicit memory block automatically move to the Explicit memory block. Therefore, you need not set the movement from the Java heap to the Explicit memory block for the objects that have relationship with the moving objects. However, if you specify the -XX:+ExplicitMemoryUseExcludeClass option, objects of the classes that are coded in the configuration file for Explicit Memory Management functionality application exclusion do not move to the Explicit memory blocks.
Note that the Explicit memory blocks, which are created by the automatic placement functionality, are targeted for movement of objects based on a reference relationship from the Java heap to the Explicit memory block. The Explicit memory blocks created by the Explicit Management Heap API are not targeted.
- Reference note
-
Take caution if the following phenomena occur after many objects are moved to the Explicit heap when Full GC occurs. In such a case, consider taking measures to prevent objects subject to automatic movement based on reference relations from moving to the Explicit heap.
-
The processing of automatic release of the Explicit memory blocks takes time
-
Small amount of Tenured area is used
Use the following functionalities for not moving the objects to the Explicit memory block:
-
Functionality for controlling object movement to the Explicit memory block
-
Functionality for specifying classes to be excluded from an application of the Explicit Memory Management functionality
The first functionality prevents objects from moving to the Explicit heap when Full GC occurs. This functionality can reduce the time of automatic release of Explicit memory blocks. The second functionality prevents objects of the classes specified in a configuration file from moving to the Explicit heap when copy GC occurs. This functionality can reduce the number of objects that move to the Explicit heap, although it depends on the classes you specify. If you use the second functionality, the first functionality is also enabled. Use the second functionality when a large number of objects are to be moved to the Explicit heap and the processing of automatic release of Explicit memory blocks takes time even if you use the first functionality.
-
- Organization of this subsection
(1) Execution timing
This processing is performed when copy GC or Full GC occurs.
(2) Executed details
After copy GC or Full GC processing ends, the Java VM checks for any Explicit memory blocks for which no reservation for release is made. The Java VM examines the reference relationship from the objects that are the basis of investigation, and continues the investigation until there are no more references. The areas other than the Java heap are not targeted for the investigation of a reference relationship. The objects referenced from the Explicit memory block are targeted for movement.
-
For copy GC
In addition to the preceding action, the Java VM performs operation according to the following rules when copy GC occurs:
-
Move an object when the object in the Explicit memory block that is being referenced, promotes.
-
Do not target objects for investigation if they are referring to the Metaspacr area, Explicit heap and the Tenured area.
-
Even if an Explicit memory block is reserved for release, consider it as targeted for moving.
This case corresponds to the ones when objects cannot be moved because the area of the Explicit memory block cannot be secured and there is no free space in the movement destination Java heap when the object moves to the Java heap. In this case, Full GC is performed and free space is secured in the Java heap. The objects move to the Java heap after Full GC ends.
-
-
For Full GC
In addition to the preceding action, the Java VM performs operation according to the following rule when Full GC occurs:
-
If you specify 1 in the -XX:ExplicitMemoryFullGCPolicy option, the objects targeted for movement on the basis of a reference relation are not moved to Explicit memory blocks. The objects in the New area are moved to the Tenured area.
-
Figures 7-10 and 7-11 describe the flow of the movement of objects in accordance with these rules with examples. Specifying 0 in the -XX:ExplicitMemoryFullGCPolicy option is a prerequisite for the flow of the movement of objects described here.
|
The objects in the figure move in the following sequence:
-
Object 1 is being referenced from an object in the Explicit memory block 1. Therefore, the object 1 moves to the Explicit block 1.
-
Object 9 also moves to the Explicit memory block 1 because it is being referenced from the object 1.
-
In the same way as in points 1 and 2, the object 4, object 10, and object 11 move to the Explicit memory block 2.
-
Object 6 is being referenced from an object in the Explicit memory block 2. However, it is not an object in the Java heap and hence it does not move.
-
In the same way as in point 4, the object 12 also does not move.
Figure 7‒11: Objects that move on the basis of a reference relationship (Example 2)
The objects in the figure move in the following sequence:
-
Object 13 is in the Java heap and can be accessed from an object in the Explicit memory block 2. However, it does not move because the investigation terminates at object 12.
-
Like object 13, the object 15 is referenced from the Metaspace area. However, in addition to the reference, the object can be accessed from an object in the Explicit memory block 2 without involving the Metaspace area or any other Explicit memory block. Therefore, it moves to the Explicit block 2.
-
Although the object 5 is being referenced from the Explicit memory block 1 as well as the Explicit memory block 2, it moves to the Explicit memory block 1.
Note that the object 5 is being referenced from the Explicit memory block 1 as well as the Explicit memory block 2. In such cases, although it moves to either the Explicit memory block 1 or 2, it is not defined to which Explicit memory block it will move to.
In the case of following conditions, operation will be different than described in the example.
-
In case you cannot secure free space in the Explicit memory block
This corresponds to the case when there is no free space in placement destination the Explicit memory block for placing objects targeted for placement at the time of placing objects in the Explicit memory block. In such cases, you cannot place object in the Explicit memory block. Objects, which cannot be placed, are placed in Java heap area. If you are using API in an incorrect way, an API level exception might occur. For details, see 10.7 Exception class in the uCosminexus Application Server API Reference Guide.