Tuesday 17 January 2012

java.lang.OutOfMemoryError: PermGen Space while starting jboss in linux

The "PermGen" error happens, when the Java virtual machine runs out of memory in the permanent generation. Recall that Java has a generational garbage collector, with four generations: eden, young, old and permanent. 

More about the error can be read from http://rlogiacco.blogspot.com/2009/02/jboss-and-permgen-outofmemoryerror.html

Solution:


The defaut PermGen space in Jave is 64MB, and you want to define a larger one.
To do so you need to set the two params -XX:PermSize=128m and -XX:MaxPermSize=128m in the JAVA_OPTS - the size is here set to 128MB - but you can set it to your own, it have to be below the max of -Xmx 
     

Step1: Go to  JBOSS_HOME/bin/ directory
Step2: Open run.conf file as shown below   
                #vim run.conf


Step3: Search for the string JAVA_OPTS
Step4: Add the two parameters as shown below


Before adding "permgen" parameters
------------------------------------------------------------------------------------
if [ "x$JAVA_OPTS" = "x" ]; then
   JAVA_OPTS="-Xms128m -Xmx512m  -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
fi
------------------------------------------------------------------------------------



After adding "permgen" parameters
------------------------------------------------------------------------------------
if [ "x$JAVA_OPTS" = "x" ]; then
   JAVA_OPTS="-Xms128m -Xmx512m -XX:PermSize=2048m -XX:MaxPermSize=2048m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
fi
---------------------------------------------------------------------------------------



Step5: Restart jboss

No comments:

Post a Comment