java.lang.OutOfMemoryError: PermGen space [closed]

2022-09-01 08:06:35

I am getting following error frequently in eclipse IDE 3.2, how could I save the application from these OutOfMemory?

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)

答案 1

If you are getting the questioned error in the secondary Eclipse Application, adding in won't help. You need to go into and add that piece in VM arguments.I also increased others memory limits so:-XX:MaxPermSize=512minidebug or run configuration->arguments

-Dosgi.requiredJavaVersion=1.5 -Xms120m -Xmx2048m -XX:MaxPermSize=1024m

It helped.

Edit. After some experiments I've found, that Eclipse does take memory limits from the ini file. But... it does it only once, at the creation of a new workspace. Parameters from -vmarg in eclipse.ini create the default VM parameters line. So, if you are working on the existing workspace, change debug or run configuration. But change eclipse.ini, too, for better future.


答案 2

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

-Xms256m
-Xmx512m
-XX:MaxPermSize=512m

Assuming you've at least 2GB of RAM.

See also: