Jboss and java.lang.OutOfMemoryError: PermGen space

Once again, this infamous exception blew at my face when starting JBoss 4.2.3.GA today !
In fact, JBoss had to deploy 2 wars, one of them being a Web Service deploying war.
This exception occurred for one simple reason : the permgenspace is where class properties, such as methods, fields, annotations, and also static variables, etc. are stored in the Java VM, but this space has the particularity to not being cleaned by the garbage collector.
So if your webapp uses or creates a lot of classes (I’m thinking dynamic generations of classes), chances are you met this problem.
Here are some solutions that helped me get rid of this exception :

  • -XX:+CMSPermGenSweepingEnabled : this setting enables garbage collection in the permgenspace
  • -XX:+CMSClassUnloadingEnabled : allows the garbage collector to remove even classes from the memory
  • -XX:PermSize=64M -XX:MaxPermSize=128M : raises the amount of memory allocated to the permgenspace

These options must be included in the JAVA_OPTS part of your Jboss run.bat or run.sh startup file.

Thank you Stephane for giving me the solution !

9 réflexions sur « Jboss and java.lang.OutOfMemoryError: PermGen space »

  1. Hi, Thanks for posting.I tried the Garbage collecter uses as —> System.gc(); I m actually parsing the location of images from sdcard(pictures.xml file). But unable to get the correct values all times… What i do?

  2. Got the same issue with 5.0.1.GA. In this case, -XX:+CMSClassUnloadingEnabled is enough!

    Thank you from Italy
    ~pasquale

  3. Hi,i’ve got same error and i’m trying many times to change JAVA_OPTS into run.conf but it’s still same size after check it by jmap…pls, do you have any suggestions..?
    i’ve jboss 4.2.2GA, java hotspt server 64 bit, red hat centos, 8GB

  4. Hi Hazem,
    It is not so simple to answer – what kind of options do you pass
    ss ? have you run GC logs to verify if PermGen is collected ? I was just working on PermGen OOM issue and root cause analysis is very time consuming in applications larger than « HelloWorld »

    Regards

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *