tags:

views:

78

answers:

3

i get this exception frequently when running my app 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)
+2  A: 

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

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

and take a look here:

How to deal with “java.lang.OutOfMemoryError: PermGen space” error

Chris
A: 

I got this problem today as well. It happened completely out of the blue. Yesterday I've updated JDK/JRE from 1.6.0_13 to 1.6.0_21 to fix a Glassfish 3.0.1 specific issue and Eclipse suddenly broke with those OutOfMemoryError: PermGen space errors. After (incorrectly) ranting on the Glassfish plugin and concluding that the issue wasn't fixed after cleaning the workspace metadata, it turns out that this is caused by the change of JVM vendor string from "Sun" to "Oracle" since 1.6.0_20. Eclipse didn't recognize the new JVM vendor and thus didn't apply the VM arguments as specified in eclipse.ini.

This was reported as Eclipse issue 319514 and the Eclipse boys quickly released a patch. Until they get it fixed more permanently, the workaround is indeed to add the following lines to the eclipse.ini:

-XX:MaxPermSize=256m

So, if you recently did a JVM update, it might be worth to take a look to it.

BalusC