7.13.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.