Home > 16ms > How to escape from PermGen-Space hell( or escape from “Die Strafe Gottes”)?

How to escape from PermGen-Space hell( or escape from “Die Strafe Gottes”)?

How many times on a day have you a PermGen-Space Exception? So you must restart an application server and that makes you really angry. So what we can do ?

The easy way to have one workaround is to add java option for better handling this problem. On the jboss application server try to change the JAVA_OPTS in the run.(bat/sh) with flower options:

With Sun JVMs reduce the RMI GCs to once per hour

set  JAVA_OPTS=%JAVA_OPTS% -Xms512m -Xmx512m -XX:+UseConcMarkSweepGC \
    -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -XX:PermSize=128m \
    -XX:MaxPermSize=256m -Dsun.rmi.dgc.client.gcInterval=3600000 \
    -Dsun.rmi.dgc.server.gcInterval=3600000

By default PermGenSpace is set with value of 64mb, which is to small for large Applications. So what we must add is simple three options :

-XX:+UseConcMarkSweepGC ( UseConcMarkSweepGC tells the JVM to use the concurrent low-pause collector for the old generation heap; as most of the collection with this collector is done in parallel with the application threads, it only has a few brief stop-the-world pauses, instead of one large pause.)
-XX:+CMSPermGenSweepingEnabled
-XX:+CMSClassUnloadingEnabled
-XX:PermSize=128m -XX:MaxPermSize=256m (The MaxPermSize=128m sets a new max for the JVM which can help with some of the Java.lang.OutOfMemoryError issues some people see.)

have nice day,

AVC (Arkadiusz Victor Czarnik)

PS. It’s optimze the performance of the application-server also. :-)

Categories: 16ms Tags:
  1. March 6th, 2008 at 15:55 | #1

    Hi,

    when you use the shell script (run.sh) to start the server, you should, of course, add these JAVA_OPTS to the run.conf instead of the run.sh directly, as it’s sourced in the script and is there to hold such configuration entries…

    Cheers,
    -makii

  1. No trackbacks yet.
You must be logged in to post a comment.