7.4.1 How to estimate the memory size of Java heap
When tuning JavaVM, you need to properly estimate the memory size of each area of JavaVM specific area.
Estimate the following memory sizes:
-
Memory size of the entire Java heap
-
Memory size of the Tenured area
-
Memory size of the Survivor area
-
Memory size of the Eden area
In addition, estimate the Metaspace area, as and when required.
When the size of existing objects after executing copy GC is greater than the size of the Survivor area, the Survivor area becomes full and some of the objects are promoted to the Tenured area on one execution of copy GC. Also, when the size of the Survivor area is small and the usage of the Survivor area increases, the Java objects with a short lifespan (objects with a lifespan lesser than the copy GC interval or objects with a lifespan one to two times of the copy GC interval) are promoted to the Tenured area with multiple executions of copy GC.
- Tip
-
If you observe any of the following issues, the Full GC was triggered by the Survivor area becoming full. Also, the extended verbosegc information is output to the JavaVM log file when GC occurs, if the option is set when starting the J2EE server.
-
When the objects with a short lifespan are identified as a reason for increase in the Tenured area
-
When it is confirmed that the Survivor area is full during the execution of copy GC in the extended verbosegc information
-
When it is observed that the age for promoting objects is always one in extended verbosegc information if specifying -XX:+HitachiVerboseGCPrintTenuringDistribution.
To avoid such problems, you must reduce the setup value of the -XX:SurvivorRatio option, and optimize the ratio of the Eden area and the Survivor area.
-
When estimating consider these points and first calculate the memory size of the Tenured area and the New area, and based on this memory size, calculate the memory size of the entire Java heap.
The following figure shows the order for estimating the memory size. Estimate in the sequence of the numbers given in the figure:
|
|
The estimation procedures are given below. The numbers correspond to the numbers in the figure.
-
Estimate the memory size used in the Tenured area.
For details about how to estimate, see 7.5 Estimating the memory size of the Tenured area in Java heap.
-
Estimate the memory size used in the Survivor area.
For details about how to estimate, see 7.6.1 Estimating the memory size of the Survivor area in Java heap.
-
Estimate the memory size used in the Eden area.
For details about how to estimate, see 7.6.2 Estimating the memory size of the Eden area in Java heap.
-
Calculate the memory size of the entire New area by adding 2. and 3.
-
Determine the handling of objects that exist for a fixed time period, and add the necessary memory size to the memory size of either the Tenured area or the New area.
For details about how to determine, see 7.7 Determining the handling of objects that exist for a fixed time period in Java heap.
-
Calculate the memory size of entire Java heap by totaling 1, 4, and 5.
-
When required, estimate the memory size of the Metaspace area.
For details about how to estimate, see 7.9 Estimating the memory size of the Metaspace area in Java heap.