Sun Microsystems Logo
First Previous Next Last Overview
 

LAB-1205: Java Application Performance Analysis

Exercise 2: Young generation too big

Learning goals of this exercise

In this exercise you will learn:

Background for this exercise

Please see Exercise 1 for an overview of running the javaperf GUI launcher.

General Guidelines for sizing the young generation:

Steps to follow

  1. For this exercise we keep the maximum heap size the same at 16 MB.  However we set the young gen all the way to 5.5 MB. (remember for exercise 01 we set the Young gen too small at only 1 MB)
    Here are the settings for Exercise 02:
    compiler=
    heap=-XX:NewSize=5500k -XX:MaxNewSize=5500k -Xms16m -Xmx16m
    gc=
    other=

  2. Remember that you can view these settings within the javaperf GUI by clicking on the Settings tab. In this exercise we have no compiler, gc or other arguments. We only setting the initial and maximum Young Gen size and the initial and maximum overall heap size.

  3. Click [Start]. You will see the Java 2D Demo application start....  Immediately click on the "Transforms" tab.

  4. Then click into the "Shear" area so it fills the entire window.

  5. Notice that there is no longer the sawtooth pattern in the old gen graph in the "Graph" pane of Visual GC.  You may also notice that the application is somewhat "jittery" due to the fact that each minor GC takes longer (it has to collect 5.5 MB instead of 1 MB).

  6. When you see that the application runtime goes just over one minute, as shown at the top of the "Visual GC" pane then
    quit the Java 2D Demo application by clicking [Stop]

  7. Notice the summary statistics in the javaperf GUI. For this example run we have had 17 minor collections (vs. 105 in Exercise 1), 4 full collections (vs. 3) and we have a spent a total of 2.45% (vs. 3.45%) of the total runtime in GC. (PLEASE NOTE: your numbers will be different than these examples)

Summary

How do you know the young gen is too big?  One way is if you have a bad young gen to max heap ratio (we will explore this possibility in Exercise 4).
Even though you have fewer GC's, they take longer when they occur.

Why is a big young gen a problem?  Having the young gen too big is generally not as big a performance problem as having it too small. One concern, especially for client applications, is that if the young gen is too big it can lead to jittery response due to GC pauses during minor collections.  If you really do want better throughput (less time in GC) and are willing to give up responsiveness then a larger young gen may be better.

Another concern is that the overall heap size may be bigger than necessary (and thus wasting memory). 

Next Steps