Sun Microsystems Logo
First Previous Next Last Overview
 

LAB-1205: Java Application Performance Analysis

Exercise 7: Permanent generation too small

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.

For most applications tuning the permanent generation is optional.  However if you want to optimize your application for memory consumption then tuning the perm gen will be a very important step.  Remember, the space used by the perm gen is NOT counted when you set the maximum heap (with -Xmx).

Steps to follow

  1. For this exercise we reset the maximum heap size to our standard 16 MB.  We keep the young gen at our optimal 4 MB.  And now we introduce perm gen tuning by setting it to 6 MB.
    compiler=
    heap=-XX:PermSize=6m -XX:MaxPermSize=6m -XX:NewSize=4m -XX:MaxNewSize=4m -Xms16m -Xmx16m
    gc=
    other=

  2. Click [Start]. You will see the Java 2D Demo application start.... 
    Warning: the Java 2D Demo application might get stuck!

  3. You will see that (if the Java 2D Demo application doesn't crash) Visual GC shows the application is alive, but nothing is happening.  All the Graphs are flatlined -- it is stuck!

  4. To stop the stuck Java 2D demo click on [Stop]
    It is possible that even the javaperf GUI launcher cannot stop the Java 2D demo. If that happens then you have to resort to a platform specific method to kill the Java 2D Demo program. On Windows you can type Ctrl-Alt-Delete to bring up the Task Manager, then find the Java 2D demo, and click on End Application. On Solaris or Linux run the xkill command (either from a menu or the command line console) and click on the the Java 2D Demo window. On UNIX you can confirm that Java 2D is no longer running by checking for vmid's with jps -ml. If you still see Java 2D Demo listed then you will probably need to do kill -9 <vmid>

Summary

How do you know when the perm gen is too small?  If the application doesn't start or crashes with an out of memory exception.

Why is a perm gen that is too small a problem?  If the permanent generation is too small there won't be enough room for the JVM to load the jars and classfiles that comprise the application itself.  Even if the there is enough memory on the heap, the JVM can't operate without enough space to dynamically interpret (profile hotspots and possibly compile) your application code.

Next Steps