Friday, March 28, 2008

java.lang.OutOfMemoryError: PermGen Space in JBOSS

We all are Blank/ Confused/ Shocked/ worried as soon as Console displays "java.lang.OutOfMemoryError: PermGen Space"

Many Questions come to our mind..What is wrong? Should I increase the memory Size? Why my application in consuming more than the 64m(default size allocated to Perm Gen Space)

Though -Xms and -Xmx can change the default memory sizes taken up by the JVM but still we all frequently encounters this error "java.lang.OutOfMemoryError: PermGen Space" and to be more precise I have frequently faced it in Jboss.

The answers for this lies in the sizes which are allocated to various memory areas within a hotspot/ VM's. (please visit my earlier Post to know more on this)
No doubt that this is the right time to profile your application and find out the memory leaks but still you cannot afford to shutdown your application and let your business loose thousands of dollars (That's what Sales people are accustomed to :))

Though there are very few solutions available in market but some of them which I have tried and they worked like a Champion are: -
1. Use JRocket. It worked and till date I haven't seen that Ugly PermGen Error.
2. Profile your application and find out memory leaks (we already talked about that).
3. Over the period of time may be your application has increase in the size/ users/ features etc and you need to re-think about the memory provided to your application.
4. One of the Shortest possible solution could be increase the "PermSize". That's not the optimal solution but it works atleast with JBOSS and JDK1.5.06 it works.(-Xms256m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=512m Runtime VM Option)

No comments: