7.3.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:

In addition, estimate the Permanent area, as and when required.

When the size of existing objects after executing copy garbage collection 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 garbage collection. 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 garbage collection interval or objects with a lifespan one to two times of the copy garbage collection interval) are promoted to the Tenured area with multiple executions of copy garbage collection.

Hint
When you are able to confirm the following problems, you will understand that a full garbage collection occurs due to the insufficient Survivor area. Also, the extended verbosegc information is output to the JavaVM log file when garbage collection 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 garbage collection 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:

Figure 7-10 Order for estimating the memory size

[Figure]

The estimation procedures are given below. The numbers correspond to the numbers in the figure.

  1. Estimate the memory size used in the Tenured area.
    For details about how to estimate, see 7.4 Estimating the memory size of the Tenured area in Java heap.
  2. Estimate the memory size used in the Survivor area.
    For details about how to estimate, see 7.5.1 Estimating the memory size of the Survivor area in Java heap.
  3. Estimate the memory size used in the Eden area.
    For details about how to estimate, see 7.5.2 Estimating the memory size of the Eden area in Java heap.
  4. Calculate the memory size of the entire New area by adding 2. and 3.
  5. 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.6 Determining the handling of objects that exist for a fixed time period in Java heap.
  6. Calculate the memory size of entire Java heap by totaling 1, 4, and 5.
  7. When required, estimate the memory size of the Permanent area.
    For details about how to estimate, see 7.8 Estimating the memory size of the Permanent area in Java heap.