Wednesday, March 7, 2012

Permanent Generation in Java

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. For more details on this area please refer to: http://middlewaremagic.com/weblogic/?p=4456.
.
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”
Example: you can see following kind of Trace in the Server/Stdout Logs:



02 Exception in thread "[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'" java.lang.OutOfMemoryError: PermGen space

03 at java.lang.ClassLoader.defineClass1(Native Method)

04 at java.lang.ClassLoader.defineClass(ClassLoader.java:621)

05 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)

06 at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)

07 at java.net.URLClassLoader.access$000(URLClassLoader.java:56)

08 at java.net.URLClassLoader$1.run(URLClassLoader.java:195)

09 at java.security.AccessController.doPrivileged(Native Method)

No comments:

Post a Comment