tags:

views:

156

answers:

4

I am getting follwoing error frequently in eclipse IDE 3.2, how do I solve it

java.lang.OutOfMemoryError: PermGen space
    java.lang.ClassLoader.defineClass1(Native Method)
    java.lang.ClassLoader.defineClassCond(Unknown Source)
    java.lang.ClassLoader.defineClass(Unknown Source)
    java.security.SecureClassLoader.defineClass(Unknown Source)
    org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1814)
    org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:872)
    org.jboss.web.tomcat.service.WebAppClassLoader.findClass(WebAppClassLoader.java:75)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1325)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
    com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:289)
    java.sql.DriverManager.getConnection(Unknown Source)
    java.sql.DriverManager.getConnection(Unknown Source)
    org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
    org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:111)
    org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)
    org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)
    com.mfic.util.HibernateUtil.<clinit>(HibernateUtil.java:16)
    com.mfic.dao.BaseHome.getSession(BaseHome.java:16)
    com.mfic.core.helper.UserManager.findByUserId(UserManager.java:248)
    com.mfic.core.action.Login.authenticate(Login.java:39)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    java.lang.reflect.Method.invoke(Unknown Source)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
A: 

Your project eats a lot of memory. Give Eclipse more memory to work with. Edit eclipse.ini to modify or add the following lines below -vmargs.

-Xms256m
-Xmx512m
-XX:MaxPermSize=512m

Assuming you've at least 2GB of RAM.

See also:

BalusC
A: 

Hi there,

This happens pretty frequently when running Tomcat inside Eclipse during debug sessions etc. From memory, it's an issue with the Sun JVM. Annnyway, there's an easy fix:

Just add the following below your -vmargs in eclipse.ini (which is in the same directory as your eclipse binary):

-XX:+UseConcMarkSweepGC
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled 

This will enable a more aggressive garbage collection while running Eclipse, and is a more elegant solution than just throwing more RAM at Eclipse.

Hope this helps!

Sam Day
A: 

Increase your MaxPermSize in your eclipse.ini. I suggest setting it to 128M or 256M if you're confortable with RAM

-vmargs -XX:PermSize=64M -XX:MaxPermSize=128M  

Also note that lots of people faced PermGen problems with Eclipse 3.2 as reported in Perm-Gen Errors Got You Down?. And since Eclipse 3.2 is more than 4 years old, I'd suggest upgrading to a more recent version (Eclipse 3.6 is the current version).

References

Pascal Thivent
A: 

The answers above probably solve it for you, but here are some interesting relevant links anyway:

Here is an article with a lot of discussion and suggestions about this error: http://www.jroller.com/agileanswers/entry/preventing_java_s_java_lang

Discussion of an example of how a Permgen OOM error can occur: http://blogs.sun.com/fkieviet/entry/classloader_leaks_the_dreaded_java

Here is an actual solution, posted on StackOverflow recently. It is for Tomcat but may be useable in Eclipse: http://stackoverflow.com/questions/88235/how-to-deal-with-java-lang-outofmemoryerror-permgen-space-error

Beel