This recipe, taken from the Oracle SOA Suite 11g Performance Cookbook, looks at how increasing the permanent generation size. Permanent Generation (PermGen) is a special part of the Java heap which contains the Class templates for all of the Java Classes on your classpath. The size of the Permanent Generation heap can be controlled via the -XX:PermSize and -XX:MaxPermSize flags. Note that this is not a feature of the JRockit JVM (which stores its classes in the heap), as such this tip does not apply if you have chosen that JVM.
You will need to have installed Oracle SOA Suite 11g for this recipe. This command is the same whether you're using the Hotspot or JRockit JVM.
How to do it…
Follow the steps below to configure the permanent generation size.
1. Navigate to the domain home directory.
Replace soa_domain with the relevant domain as required.
2. Within the /bin folder you will see a number of scripts. Depending on your platform you will need to edit a different file; setSOADomainEnv.cmd on Windows or setSOADomainEnv.sh on Linux. Note that it is a good idea to take a backup of these files before editing them.
3. Open the file and locate the section below. Note that I have manually placed the @REM comment; your file will not contain this line.
4. In DEFAULT_MEM_ARGS and PORT_MEM_ARGSset the value of -XX:PermSize and -XX:MaxPermSize to your new values. A good rule of thumb is to stick to powers of 2, with 256MB as the minimum and 1024MB as the maximum starting values.
5. Start the server by running and view the output to verify your change (note below, I only set my minimum to 256MB and maximum to 640MB in order to show a change from the default values on a 32 bit machine)
How it works…
The Permanent Generation Heap space (PermGen) is a feature of the Hotspot JVM designed to prevent the bloat of the Tenured (Old) Java heap space, and thus allow the Garbage Collection routines to ignore these classes during their main execution runs.
However there is a problem with this design; the PermGen space forms a total part of the total Memory required by the Java process. In other words you must add this to the XMX Maximum Heap Space (and other values, see the tip 'Calculate the total memory used by your application') to determine the full memory usage of your application. Setting the PermGen to large values, especially on 32 bit machines, subtracts from the total memory available for your applications objects. This explains why the PermGen is by default set to quite a small value.
So why increase it? And what's a java.lang.OutOfMemoryError: PermGen space exception? The answers to these questions are to do with class loading in Java, which is a deep subject beyond the scope of this chapter. Suffice to say that there are two main points to consider when setting these values.
1. Large applications with a high number of classes will require more PermGen space to store their class templates. SOA Suite is a large application, hence our recommendation to increase the value.
2. Every time you redeploy an application a new class loader is used. This will load all the classes in that application in isolation. Thus if you are redeploying a large application you effectively have two instances of each of your classes in the PermGen memory space until the old application is undeployed (and sometimes not even then, but that's another topic!). SOA Suite itself is not redeployed regularly so this is less of an issue for us here.