7.5.2 Reason for adding the memory size of the New area in Java heap
In the memory size of the Tenured area, Hitachi recommends you to add the memory size of the New area to the minimum required memory size of the application. This is to prevent frequent occurrence of Full GC, as the unused memory size of the Tenured area is lesser than the used memory size of the New area.
Usually, copy GC occurs when the Eden area becomes full. At that point, the Java objects in use that exist in the Eden area and the From space of the Survivor area try to move to the To space of the Survivor area. If, however, the unused area of the Tenured area is lesser than the memory size that is in use in the Eden area and the Survivor area, and all the Java objects of the New area are promoted, the Java objects in use do not move to the Tenured area. At this point, the JavaVM triggers Full GC and attempts to increase the unused memory size in the Tenured area.
To prevent this, apart from the memory size required by application, add the memory size equivalent to the New area, in the Tenured area.
The following figure shows this concept:
-
An example where Full GC occurs because the objects might not be able to be promoted
The free space in the memory of the Tenured area (the area besides the memory area required by the application) is lesser than the memory size of the New area. Therefore, when the number of objects moving from the Eden area and From space is large, the objects cannot be promoted. In this scenario, Full GC occurs.
-
An example, wherein the objects can certainly be promoted
The free space in the memory of the Tenured area (the area besides the memory area required by the application) is allocated equivalent to the size same as the New area. Therefore, even when the number of objects moving from the Eden area and From space is large, the objects can be promoted.
For details about estimating the memory size of the New area, see 7.6 Estimating the memory size of the New area in Java heap.
- Tip
-
If checking the extended verbosegc information and other resources reveals that Full GC occurs frequently without copy GC occurring, you can conclude that the memory size of the Tenured area is too small for the objects promoted from the New area. This situation occurs when the size of the New area is increased. Modify the memory size of the Tenured area, as and when required. Also modify the relation between the Eden area and the Survivor area of the New area.