Sun Microsystems Logo
First Previous Next Last Overview
 

LAB-1205: Java Application Performance Analysis

Exercise 8: Permanent generation sized just right

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.

In the previous exercise, Exercise 7, we demonstrated the result of setting the perm gen too small.

Steps to follow

  1. Now we set the perm gen to 12 MB (instead of 6 MB for Exercise 7).  The overall heap and new size remain the same at 16 MB and 4 MB respectively.
    compiler=
    heap=-XX:PermSize=12m -XX:MaxPermSize=12m -XX:NewSize=4m -XX:MaxNewSize=4m -Xms16m -Xmx16m
    gc=
    other=

  2. Click [Start]. You will see the Java 2D Demo application start....  Immediately click on the "Transforms" tab. Then click into the "Shear" area so it fills the entire window.

  3. Notice that there is plenty of room in the perm gen area.

  4. When you see that the application runtime goes just over one minute click [Stop]

  5. Note that this is very similar to our results in Exercise 3 (which used default perm gen sizing).  The main difference here is that we are using less overall memory and we have avoided some resizing of the permanent generation.

Summary

How do you know the perm gen is sized just right?  When you find that the program runs with a comfortable margin of perm gen space.

Can I let the JVM figure the right perm gen size?  Sure, in fact you may want to set initial and maximum values for NewSize and PermGen just like for Total Heap as described in the Total Heap section of the Tuning Garbage Collection with the 5.0 Java™ Virtual Machine document.   As with the old gen exercises, however, we've opted instead to set these values the same to lead to more predictable results.

Why is having a tuned perm gen important?  If controlling overall memory consumption is important and you want to gain an incremental performance benefit by not resizing the perm gen then you gain some performance by tuning it for your application.  Note that applications that do a significant amount of classloading and unloading may need to allow for additional perm gen space.

Next Steps