eclipse java.lang.OutOfMemoryError:带有eclipse的tomcat中的PermGen空间

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3179141/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 19:29:47  来源:igfitidea点击:

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

eclipsetomcat

提问by Mahmoud Saleh

i get this exception frequently when running my app on tomcat using eclipse:

使用 Eclipse 在 tomcat 上运行我的应用程序时,我经常收到此异常:

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)

回答by Chris

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

尝试提高perm空间,将以下参数添加到vm启动中

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

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

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

还要在 Eclipse中将-XX:MaxPermSize=256m添加到 Tomcat:Server > Open Launch Configuration > Arguments

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

更新(2014 年):这里查看有关新 Java 8 元空间的问题和答案

and take a look here:

看看这里:

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

如何处理“java.lang.OutOfMemoryError: PermGen space”错误

回答by Ali

You can configure these arguments for eclipse:

您可以为 Eclipse 配置这些参数:

"To solve this I stopped the server in Eclipse. Double clicked on the server in the Serverstab to open the Overview page for the server. Clicked on Open Launch Configurationand then on the Argumentstab.

“为了解决这个问题,我在 Eclipse 中停止了服务器。双击服务器选项卡中的服务器以打开服务器的概览页面。单击打开启动配置,然后单击参数选项卡。

I added the following VM arguments :

我添加了以下 VM 参数:

-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

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

参考http://malcolmmallia.com/malcblog/?p=60

回答by BalusC

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 spaceerrors. 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.

我今天也遇到了这个问题。它完全出乎意料地发生了。昨天我将 JDK/JRE 从 1.6.0_13 更新到 1.6.0_21 以修复 Glassfish 3.0.1 特定问题,而 Eclipse 突然因这些OutOfMemoryError: PermGen space错误而崩溃。在(错误地)对 Glassfish 插件进行咆哮并得出清理工作区元数据后问题未解决的结论后,事实证明这是由于自 1.6.0_20 以来 JVM 供应商字符串从“Sun”更改为“Oracle”造成的. Eclipse 无法识别新的 JVM 供应商,因此没有应用eclipse.ini.

This was reported as Eclipse issue 319514and 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:

这被报告为 Eclipse 问题319514,Eclipse 开发人员很快发布了一个补丁。在他们更永久地修复它之前,解决方法确实是将以下几行添加到eclipse.ini

-XX:MaxPermSize=256m

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

因此,如果您最近进行了 JVM 更新,可能值得一看。