java. Lang. outofmemoryerror: Web application usage on permgen space
I am trying to deal with the recent OUTOFMEMORY permgen problem One of the log fragments saved when an error occurs:
java.lang.OutOfMemoryError: PermGen space at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) at java.lang.ClassLoader.defineClass(ClassLoader.java:616) at org.apache.Felix.framework.ModuleImpl$ModuleClassLoader.findClass(ModuleImpl.java:1872) at org.apache.Felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:720) at org.apache.Felix.framework.ModuleImpl.access$300(ModuleImpl.java:73) at org.apache.Felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1733) at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
I increased the maximum capacity size - XX: maxpermgen = 128M, but this is only a temporary solution because I'm sure we're facing some memory leaks here The web part of our application is deployed on Jetty (JSF icefaces) Clicking on a random component increases the memory used - I'm using jstat - gcold to monitor it, and almost every hit means 3-4kb more I have added - XX: traceclassloading to the JVM parameter, and you can see a lot of sun when there is any operation on the web user interface reflect. Generatedconstructoraccessor and sun reflect. The generated method accessor is logged When I used 99% permgen, I also made a heap I use the yourkit parser to analyze the heap In the classloader tab, there are some sun reflect. Delegatingclassloader line, each class has 1 class What can cause memory to grow? Any help would be appreciated
Thank you in advance, Lucas
Solution
On the sun JVM, by calling JNI into the JVM implementation, reflective access to properties and methods is first performed If the JVM notices that a method or field is accessed through reflection, it will generate bytecode to perform the same operation - a mechanism called "inflation" This has an initial speed, but then the running speed is increased by 20 times If you do a lot of reflection, you will be a big winner
The bytecode is generated in the class created by the delegatingclassloader instance and occupies permgen space If this is a problem, you can set the system property sun reflect. Inflation threshold is set to 0 (zero) to turn off inflation