Feb. 24, 2011, 5:53 a.m.

JBoss Seam throwing java.lang.OutOfMemoryError: PermGen space

I have been pulling my hair out at the JBoss error:

java.lang.OutOfMemoryError: PermGen space

when trying to start JBoss. It starts fine with one of my ear files, but when I added the second ear file it loads, but on access of any page in JBoss it crashed. After two hours of this, I finally figured it out.

See, the second application is a JBoss Seam application. Why is this important? JBoss Seam has a LOT of classes that needs to be loaded, much more than my other application. This is relevant because I had this in my run.conf in JBoss:

if [ "x$JAVA_OPTS" = "x" ]; then  
  JAVA_OPTS="-Xms256m -Xmx2048m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"

This does not allow for a large enough Perm Gen space in the Java memory model. Changing it to:

if [ "x$JAVA_OPTS" = "x" ]; then  
 JAVA_OPTS="-Xms256m -Xmx2048m -XX:MaxPermSize=384m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"

fixed the issue.