Views
On the test server, in June 2007, we were periodically getting java.lang.OutOfMemoryError: PermGen space errors in the logs, making the application unusable to end users. This error indicates that available permanent generation space has been exhausted by application(s) running in the JVM, by Strings and other immutable objects.
The current thinking on the issue is just that the default allocation of 64MB is too small (see http://alessandroribeiro.com/?q=en/node/33 for the reasoning behind this)
We have increased the allocation to PermGen space in the JVM to min 128Mb and max of 256Mb and have no longer seen any issues on the test server. Though we still need to monitor this in more detail, this seems to have resolved the issue.
To resolve the issue in your local installation of Mifos, you can specify the amount of memory allocated to the PermGen when starting your application server:
There are two command-line parameters that you must use to define the size of the permgen area:
-XX:PermSize -XX:MaxPermSize.
For example:
java -Xms64m -Xmx128m -XX:PermSize=64m -XX:MaxPermSize=256m
(the first two parameters set heap size and the last two set PermGen size)
To do this in JBoss find the following lines in run.bat or run.sh in the $JBOSS_HOME/bin folder:
rem Sun JVM memory allocation pool parameters. Modify as appropriate. rem set JAVA_OPTS=%JAVA_OPTS% -Xms64m -Xmx128m -XX:PermSize=64m -XX:MaxPermSize=256m
(uncomment the second line by removing 'rem' and modify the parameters appropriately)
Notes for Tomcat.
I've been using -Xmx512m -XX:MaxPermSize?=256m on the test server.
For use on windows:
- you can use the tomcat monitor (bin/tomcat6w.exe) and enter these option on the Java Tab. (this won't work if you have multiple tomcats running)
- You can set them in the JAVA_OPTS environment variable
- If you are running tomcat as a service you can edit service.bat and add the options to the line:
"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions? "-Xmx512m;-XX:MaxPermSize?=256m;-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%endorsed" --StartMode? jvm --StopMode? jvm
reinstall the service.
For Debian Linux:
Debian-based systems such as Ubuntu are probably similar.
Edit /etc/default/tomcat5.5
Change the default settings to resemble this:
# Arguments to pass to the Java virtual machine (JVM)
# "-Djava.awt.headless=true -Xmx128M" is automatically set if CATALINA_OPTS
# is left empty here
#CATALINA_OPTS="-Djava.awt.headless=true -Xmx128M -server"
#
# GBR 20080630: Address PermGen out of memory problem
#
CATALINA_OPTS="-Djava.awt.headless=true -Xmx128M -server \
-XX:MaxPermSize=256m \
-XX:+UseConcMarkSweepGC \
-XX:+CMSPermGenSweepingEnabled \
-XX:+CMSClassUnloadingEnabled"
I may change -Xmx128M as per the other notes, but one change at a time...
