Java.lang.OutOfMemoryError: PermGen space in tomcat with eclipse

I often get this exception when running my application on tomcat using eclipse:

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 java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1850) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:890) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1354) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) at java.lang.ClassLoader.defineClass(ClassLoader.java:616) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1850) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:890) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1354) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:265) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:180) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80) at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94) at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156) at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135) at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1650) at com.spacerdv.dao.impl.UserDaoImpl.getUserDetails(UserDaoImpl.java:170) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) 
+43
eclipse tomcat
Jul 05 '10 at 11:35
source share
3 answers

try to raise perm space, add the following parameters to vm start-up

-XX: PermSize = 256 m -XX: MaxPermSize = 256 m

also add -XX: MaxPermSize = 256 m to Tomcat in Eclipse: Server > Open Launch Configuration > Arguments

Update (in 2014): look here for this question and answer about the new Java 8 Metaspace.

and look here:

How to deal with the error "java.lang.OutOfMemoryError: PermGen space"

+93
Jul 05 '10 at 11:41
source share

You can configure these arguments for eclipse:

"To solve this problem, I stopped the server in Eclipse. Double-click on the server in the Servers tab to open the Browse page for the server. Click Open Start, and then on the Arguments tab.

I added the following VM arguments:

 -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled 

ref to http://malcolmmallia.com/malcblog/?p=60

+20
Dec 07 '11 at 10:41
source share

I have this problem today. This happened completely unexpectedly. Yesterday I upgraded the JDK / JRE from 1.6.0_13 to 1.6.0_21 to fix a specific Glassfish 3.0.1 problem, and Eclipse suddenly broke these OutOfMemoryError: PermGen space errors. After (incorrectly) smoothing the Glassfish plugin and concluding that the problem has not been fixed after cleaning the workspace metadata, it turns out that this is caused by changing the JVM provider string from "Sun" to "Oracle" from version 1.6.0_20, Eclipse does not Recognizes the new JVM provider and therefore does not apply VM arguments as specified in eclipse.ini .

This was reported as an Eclipse issue 319514 , and the Eclipse boys quickly released a patch . Until they are fixed longer, the workaround is to add the following lines to eclipse.ini :

 -XX: MaxPermSize = 256m

So, if you recently made a JVM update, it might be worth a look at it.

+5
Jul 19 '10 at 17:18
source share



All Articles