Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

eclipse

tomcat

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) 
like image 387
Mahmoud Saleh Avatar asked Jul 05 '10 11:07

Mahmoud Saleh


People also ask

How do I set PermGen space in eclipse?

Open eclipse. ini file, it is located in root eclipse directory. there you can change -Xms and -Xmx parameter to change permgen size. There you can change -XX:PermSize and -XX:MaxPermSize.

How do you fix a PermGen error?

To fix it, increase the PermGen memory settings by using the following Java VM options. -XX:PermSize<size> - Set initial PermGen Size. -XX:MaxPermSize<size> - Set the maximum PermGen Size. In the next step, we will show you how to set the VM options in Tomcat, under Windows and Linux environment.


2 Answers

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

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

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

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

and take a look here:

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

like image 185
Chris Avatar answered Oct 05 '22 10:10

Chris


You can configure these arguments for eclipse:

"To solve this I stopped the server in Eclipse. Double clicked on the server in the Servers tab to open the Overview page for the server. Clicked on Open Launch Configuration and then on the Arguments tab.

I added the following VM arguments :

-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled 

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

like image 35
Ali Avatar answered Oct 05 '22 09:10

Ali