7.12 Determining the usage of the Explicit heap using the automatic allocation functionality of the Explicit Memory Management functionality

This section describes how to determine the usage of the Explicit heap using the automatic allocation functionality of the Explicit Memory Management functionality.

You can easily use the Explicit Memory Management functionality, if you use the automatic allocation function for the Explicit heap area that uses the Explicit Memory Management functionality. Hitachi recommends that you use the automatic allocation function in the following cases:

Organization of this section
(1) When there are objects that cause increase in the Tenured area in the application
(2) When the cause of increase in the used size of the Tenured area is not known

(1) When there are objects that cause increase in the Tenured area in the application

When there are objects that cause increase in the Tenured area in the application, Hitachi recommends that you use the automatic allocation setup file and allocate the objects to Explicit heap. A good example of Java program, with which you can determine the object allocation, is as follows:

01:package abcd.efg;
02:import java.util.HashMap;
03:// KVStorage-instance-continues-to-exist-for-a-long time
04:class KVStorage {
05: HashMap _map = new HashMap();
06:
07: public void store(MyKey k,MyData d) {
08: // ...before-processing ...
09: _map.put(k,d);
10: // ...after processing...
11: }
12:
13: public MyData load(MyKey k) {
14: // ...before-processing...
15: MyData d = map.get(k);
16: // ...after processing...
17: return d;
18: }
19:}

In this setup example, the HashMap class, where KVStorage is stored to instance field, is the object with a long lifespan that causes increase in the memory size of the Tenured area. To change the generation destination of this object to Explicit heap, specify the automatic allocation setup file as described in the following example:

#Described for generation position (method name or class name), class name to be generated.
abcd.efg.KVStorage.<init>, java.util.HashMap

Alike this example, you can change the position for generating HashMap instance (_map) on 5th line in Java program example from Java heap to Explicit heap. You can also move the MyKey instance and MyData instance saved in _map by the store method sequentially to Explicit heap. These instances are automatically released by JavaVM when they are not required.

(2) When the cause of increase in the used size of the Tenured area is not known

Even after implementing the Survivor area tuning, there is an increase in the used size of the Tenured area. As a result, when the occurrence interval of full garbage collection does not fulfill the system requirements, the objects that cause increase in the used size of the Tenured area are generated in Explicit heap. Set the automatic allocation setup file of Explicit Memory Management to generate objects in Explicit heap.

The following point describes how to investigate the objects that cause increase in the used size of the Tenured area and how to setup the automatic allocation setup file:

(a) Investigating increase in the used size of the Tenured area

Specify the -garbage option in the jheapprof command for the applications that are running, and execute the unused objects statistical function in the Tenured area.

In earlier versions than 08-70, to use the -garbage option concurrently with the automatic allocation function (-XX:+HitachiAutoExplicitMemory) of Explicit memory block, you must start the Application Server in a status where the -XX:-HitachiExplicitMemoryPartialTenuredAreaCollection option is specified beforehand.

The following is an output example of unused object statistical function in the Tenured area. This function outputs the list of class names of objects (basic objects that cause increase in the Tenured area) that cause increase in the used size of the Tenured area to Thread dump log file:

Garbage Profile Root Object Information
-----------------------------------
*, java.util.HashMap # 35234568​
*, java.util.WeakHashMap # 4321000​

In this output example, it is understood that the java.util.HashMap object is of 35,234,568 bytes and the java.util.WeakHashMap object is of 4,321,000 bytes that is the cause for increase in the used size of the Tenured area. For details about the unused object statistical function in the Tenured area, see 9.8 Unwanted object statistical function in the Tenured area in the uCosminexus Application Server Maintenance and Migration Guide.

(b) Description of the automatic allocation setup file

Enter some part of output examples list (last 2 lines) of the unused object statistical function in the Tenured area to automatic allocation setup file. An example for setting automatic allocation setup file is as follows:

*, java.util.HashMap # 35234568​
*, java.util.WeakHashMap # 4321000​

In such cases, all the java.util.HashMap objects and java.util.WeakHashMap objects in the program are generated in Explicit heap.

All the objects saved in above objects are moved sequentially to Explicit heap. The runtime overhead when generating objects in Explicit heap is higher as compared to generating objects in Java heap. Therefore, when generating objects in Explicit heap, you can reduce the runtime overhead by setting up the objects generating.

In the automatic allocation setup file, * indicates all-the-classes-running-in-JavaVM. In this setup example, the position for generating java.util.HashMap and java.util.WeakHashMap objects in all the classes is Explicit heap. As a result, the position for generating objects that do not cause increase in the used size of the Tenured area is Explicit heap, and this might cause an increase in Explicit heap.

By specifying *, when the throughput of applications does not fulfill the requirements, determine the methods to sort positions for generating objects that cause increase in the used size of the Tenured area.

When the system administrator and application developer are two different people, the request for investigations must be sent to application developer. Even though it is difficult to perform detail investigation of the application, you can specify positions for generating objects in 4 stages such as "All classes", "Specific packages", "Specific classes", and "Specific methods" in the automatic allocation setup file. You can implement sorting on the range where investigations can be performed and can improve the throughput by specifying the automatic allocation setup file.

For example, when the position for generating object is under the com.abc.defg package, by changing the example for setting the automatic allocation setup file as follows you can sort from "All classes of all packages" to "All classes of com.abc.defg package and sub packages":

com.abc.defg.*, java.util.HashMap # 35234568​
com.abc.defg.*, java.util.WeakHashMap # 4321000​

For details about how to specify the automatic allocation configuration file, see 8.13.2 Using the Explicit Memory Management functionality with the automatic allocation configuration file in the uCosminexus Application Server Expansion Guide.

(c) Investigating applications by the unused object statistical function in the Tenured area

To investigate the application based on contents of the automatic allocation setup file, use the unused object statistical function in the Tenured area.

Specify the -garbage option in the jheapprof command and execute the unused object statistical function in the Tenured area to output the list of basic objects that cause increase in the Tenured area and the statistical information of unused objects in the Tenured area to the extended thread dump. The following is an output example of extended thread dump:

Garbage Profile
---------------
________________Size__Instances__Class________________
           35234568​     10648 java.util.HashMap
            5678900​     10668 [Ljava.util.HashMap$Entry;
            4456788​      7436 java.util.HashMap$Entry
            4321000​       200 java.util.WeakHashMap
            1234568​       190 [Ljava.util.WeakHashMap$Entry
1456788​      9524 java.lang.String
1256788​      6424 com.abc.defg.MyData;
:

There are objects that are saved to java.util.HashMap or java.util.WeakHashMap and not output to list of basic objects that cause increase in the Tenured area. These objects are output by the unused object statistical function in the Tenured area. The number of instances of each object are also output.

You can acquire this log multiple times and provide the log as an input file for the class-wise statistical information analysis function (jheapprofanalyzer command) to investigate the changes in each object size and time of the number of instances.

Investigate the applications based on the above information and sort the positions for generating objects. For details about the unused object statistical function in the Tenured area, see 9.8 Unwanted object statistical function in the Tenured area in the uCosminexus Application Server Maintenance and Migration Guide. For details about the class-wise statistical information analysis function, see 9.10 Class-wise statistical information analysis function in the uCosminexus Application Server Maintenance and Migration Guide.