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 comments to Jboss and java.lang.OutOfMemoryError: PermGen space

Leave a Reply

  

  

  


6 + 2 =

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">