The What and Why of fixing java.lang.OutOfMemoryError: PermGen space

The permanent generation is the area of heap that holds all the reflective data of the virtual machine itself, such as class and method objects (also called “method area” in The Java Virtual Machine Specification).

Translation: PermGen holds the information that makes the JVM work.

Why do you care?

If an application loads “too many” classes then it is possible it will abort with an OutOfMemoryError. The specific error is: “Exception in thread XXXX java.lang.OutOfMemoryError: PermGen space”

Translation: The JVM itself needs memory to be able to run your application. The PermGen is information about the classes that make up your application. Web applications and Servlet containers often need more PermGen memory than the JVM defaults to be able to run.

Fixing the java.lang.OutOfMemoryError: PermGen space error.

Start your JVM with -XX:MaxPermSize=XXXm where XXX is a number like 128, 256. This will allow the JVM to allocate XXX megabytes of memory for the PermGen space if that space is needed. Here are the quick guides to configuring memory options for some popular containers. If you still have issues see my other posts about tracking down your possible memory leaks.

I highly recommend reading Pro Java EE 5 Performance Management if you’ve read this far into this post.

Translated from a giant PDF: Java 1.5 TS, Section 1.3.3

Related Posts:

One Response to “The What and Why of fixing java.lang.OutOfMemoryError: PermGen space”

  1. [...] “30. Should I increase the size of the permanent generation in the client vm? The What and Why of fixing java.lang.OutOfMemoryError: PermGen space for JBoss, Tomcat, and Weblogic [...]

Leave a Reply