Friday, March 7

What is OutOfMemory in PermGen Space?

--------- OutOfMemory in PermGen Space---------:

Permanent Generation is a Non-Heap Memory Area inside the JVM Space. Manytimes we see OutOfMemory in this Area. PermGen Area is NOT present in JRockit JVMs. 

The PermGen Area is measured independently from the other generations because this is the place where the JVM allocates Classes, Class Structures, Methods and Reflection Objects. PermGen is a Non-Heap Area.It means we DO NOT count the PermGen Area as part of Java Heap.
The OutOfMemory in PermGen Area can be seen because of the following main reasons:
Point-1) Deploying and Redeploying a very Large Application which has many Classes inside it.

Point-2) If an Application is getting deployed/Updated/redeployed repeatedly using the Auto Deployment feature of the Containers. In that case the Classes belonging to the application stays un cleaned and remains in the PermGen Area without Class Garbage Collection.

Point-3) If ”-noclassgc” Java Option is added while starting the Server. In that case the Classes instances which are not required will not be Garbage collected.

Point-4) Very Less Space for allocated the “=XX:MaxPermGen”

---------What to do in case of OutOfMemory In PermGen---------:

Point-1) Make Sure that the PermGen Area is not set to a very less value.

Point-2) Usually if an Application has Many JSP Pages in that case every JSP will be converted to a *.class file before JSP Request Process. So a large number of JSPs causes generation of a Large number of *.class files all these classes gets loaded in the PermGen area.

Point-3) While allocating the -XX:MaxPermSize make sure that you follow a rough Formula… which works in most of the Application Servers.
MaxPermSize = (Xmx/3) —- Very Special Cases (One Third of maximum Heap Size)
MaxPermSize = (Xmx/4) —- Recommended (One Fourth Of maximum Heap Size)

Point-4) If you are repeatedly getting the OutOfMemory in PermGen space then it could be a Classloader leak….
May be some of the classes are not being unloaded from the permgen area of JVM . So please try to increase the -XX:MaxPermSize=512M or little more and see if it goes away.
If not then add the following JAVA_OPTIONS to trace the classloading and unloading to find out the root cause :
-XX:+TraceClassloading and -XX:+TraceClassUnloading.


Thanks..Naga Venkata Prasad

No comments:

Post a Comment