The efficient usage of the Explicit Memory Management functionality is greatly affected by the efficiency of the automatic release processing of the Explicit memory block. To execute the automatic release processing carefully so that a latency spike does not occur with the Explicit Memory Management functionality, divide and manage the memory areas (Explicit heap) into Explicit memory blocks, and execute the automatic release processing for the blocks. The automatic release processing of the Explicit memory block is executed during garbage collection as and when required. Also, the execution of applications stops during the automatic release processing, as in the case of a full garbage collection. Therefore, the shorter the automatic release processing time, the better the throughput and latency.
The following figure shows the automatic release processing of the Explicit memory block.
Figure B-1 Automatic release processing of the Explicit memory block
![[Figure]](figure/zu0b0100.gif)
With the automatic release processing, if the Explicit memory block subject to the automatic release processing has in-use objects, a new Explicit memory block is created and the objects are moved to this block. If there are multiple in-use objects, the automatic release processing time increases in proportion to that amount. Also, the automatic release processing must be re-executed for the new Explicit memory blocks (6 and 7 in this example), so the overall automatic release processing time also increases. Therefore, during the automatic release processing, the fewer the in-use objects in the Explicit memory block, the higher the efficiency of the automatic release processing. This also indicates that with the Explicit Memory Management functionality, the life span of the objects affects the efficiency.
Note that the following subsection describe how to select Explicit memory blocks for the automatic release processing.
- How to select Explicit memory blocks for the automatic release processing
- JavaVM selects (reserved for release) an Explicit memory block corresponding to one of the following blocks as the target of the automatic release processing.
- Blocks corresponding to the HTTP sessions destroyed between the previous and the next automatic release processing
- New blocks created during the automatic release processing
- Blocks created by the automatic allocation functionality
- However, for the blocks in 2 and 3, only the blocks selected by estimating the increment and the release ratio of the Explicit heap, or by the threshold value are subject to the automatic release processing.
- This subsection describes how to select a block by estimating the increment and the release ratio of the Explicit heap, or by the threshold value.
- Selection by estimating the increment and the release ratio of the Explicit heap
- Select multiple blocks based on the following information. Normally, this method is used.
- Increment in the Explicit heap size after the previous automatic release processing
- Release ratio of the past automatic release processing (ratio of objects that could be released automatically)
- Estimated value of the object usage rate in each block
- First, from "increment in the Explicit heap size after the previous automatic release processing", set up the target value (hereafter called the target automatic release size) of the Explicit heap size to be released automatically. The size released automatically must be more than the increment in the Explicit heap size so that the Explicit heap does not increase monotonically, and the greater the increment, the larger the target automatic release size. To automatically release the target automatic release size, calculate the size that might be selected from the total of multiple blocks (hereafter called the selection size). Even if the automatic release processing is executed for a particular block, all the objects in that block cannot necessarily be released. Therefore, based on the "release ratio of the past automatic release processing", estimate the release ratio of the objects to be released automatically. With the estimated release ratio, calculate the selection size required for reaching the target automatic release size. The lower the "release ratio of the past automatic release processing", the greater the selection size.
- Next, sort all the blocks with the "estimated value of the object usage rate in each block", if the percentage of the in-use objects is low, select the blocks sequentially from the estimated blocks. If the total size of the selected blocks reaches the selection size, discontinue the selection process. The blocks selected here are subject to the automatic release processing.
- Selection by the threshold value
- The blocks that always have a high percentage of in-use objects, and the blocks with size exceeding the selection size are not selected with "Selection by estimating the increment and release ratio of the Explicit heap". Therefore, if the size of the Explicit memory block exceeds a fixed percentage of the overall Explicit heap size (threshold value), the block is forcefully selected as a target for automatic release processing. Note that the blocks selected with "Selection by the threshold value" are not selected with "Selection by estimating the increment and the release ratio of the Explicit heap".