Notice: This resource is no longer being actively maintained and as a result some information may be out of date or inaccurate. Please see for technical instructions or for support related concerns.
RUN@cloud » JVM PermGen Space

JVM PermGen Space

Last modified by William Chan on 2012/05/15 08:08

JVM PermGen Space

JVM Permanent Generation is where most current JVM store class files (some of which are loaded when your app starts, some dynamically as your app runs). For healthy apps the permgen usage can grow a bit - but should then stop growing at some point, if it does grow too much - you will see an out of memory exception in your application which mentions Permgen space (at which point your application will be restarted). 

For most applications - the default is fine - however some frameworks (like spring, hibernate) will use a bit more space and may require some more. The Grails framework specifically now recommends 256Meg permgen space. 

The default JVM PermGen space can be changed at deployment time with the CloudBees SDK using the "bees app:deploy" command. 

usage: bees app:deploy [options] ARCHIVE_FILE [parameters]
-a,--appid <appId>          application ID (of the form accountName/applicationName)
-e,--environment <env>      environment configurations to deploy
-m,--message <message>      message describing the deployment    
-s,--secret <API secret>    Your API secret
-t,--type <container_type>  Deployment container type (tomcat | jboss)  Default: tomcat
-k,--key <API key>          Your API key

[parameters] are defined as name=value pairs.

To set the JVM MaxPermSize add the parameter: jvmPermSize=size  where size is in MB.

Note that once an application is deployed with the new parameter value, it will remain set across subsequent re-deployments. There is no need to set the parameter at each deployment.

For example to deploy the acme/test application with the MaxPermSize jvm arg set to 100MB
bees app:deploy -a acme/test target/acme.war jvmPermSize=100

If you just want to change the permgen setting for an existing app, you can run

bees app:update acme/test jvmPermSize=256

This will apply the change immediately to your app. 

Note that in both cases above the change will stay with your app even for subsequent deploys (so only need to set it once). Run bees app:info to see current settings for your app.

PermGen space and container memory

The container gives your application 64MB of PermGen space for free. Additional space is borrowed against the container max memory size

Reset to default PermGen size

To reset to the default PermGen space size set the jvmPermSize to zero (jvmPermSize=0)

Do I need to change PermGen space size?

One sign that your application might need more PermGen space is an Out of Memory exception in the log:
java.lang.OutOfMemoryError: PermGen space

Created by Fabian Donze on 2011/12/02 16:10