简体   繁体   English

Maven“线程中的异常”http-bio-8080-exec-32“java.lang.OutOfMemoryError:PermGen space”

[英]Maven “Exception in thread ”http-bio-8080-exec-32“ java.lang.OutOfMemoryError: PermGen space”

I made a project in NetBeans under Ubuntu 11.10 with Struts2 + Spring and Hibernate frameworks. 我在Ubuntu 11.10下使用Struts2 + Spring和Hibernate框架在NetBeans中创建了一个项目。 The first run is ok, but when I run it for the second or third time I keep getting this exception. 第一次运行是好的,但是当我第二次或第三次运行它时,我一直得到这个例外。 Without Maven all goes well. 没有Maven一切顺利。 I installed maven with apt-get install , and yes I added this line export MAVEN_OPTS=-Xmx512m in usr/bin/mvn , but without luck. 我用apt-get install安装了maven,是的,我在usr/bin/mvn添加了这行export MAVEN_OPTS=-Xmx512m ,但没有运气。 How to get a better performance from it? 如何从中获得更好的表现?

You should add this line: 你应该添加这一行:

export MAVEN_OPTS="-Xmx512M -XX:MaxPermSize=512M" 

Note that some users have reported that the double quotes give problems, hence you might want to use: 请注意,有些用户报告说双引号存在问题,因此您可能希望使用:

export MAVEN_OPTS=-Xmx512M -XX:MaxPermSize=512M 

EDIT: 编辑:

Since you are using Tomcat, use this: 由于您使用的是Tomcat,请使用以下命令:

  1. Open up tomcat/bin/catalina.sh 打开tomcat / bin / catalina.sh
  2. add this line to the JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC" 将此行添加到JAVA_OPTS =“ - Djava.awt.headless = true -Dfile.encoding = UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize = 256m -XX:MaxNewSize = 256m -XX:PermSize = 256m -XX :MaxPermSize = 256m -XX:+ DisableExplicitGC“
  3. Save and exit , restart Tomcat 保存并退出,重新启动Tomcat

More information here... 更多信息在这里......

permgen space usually throws this error when objects do not clear up their memory properly. 当对象没有正确清理其内存时,permgen空间通常会抛出此错误。 usually cause of 'islands' which is objects with references still pointing to them but you as the programmer dont have access to these references because they live outside your space. 通常导致“孤岛”的对象仍然指向他们,但你作为程序员不能访问这些参考,因为他们住在你的空间之外。 you are probably using a library which is causing this problem, and it probably wont go away till you stop using this library. 你可能正在使用一个导致这个问题的库,它可能不会消失,直到你停止使用这个库。 as for which library, i am not sure, there are plenty of articles explaining how to find this out, but it is a chore and may take a while unless you are lucky. 至于哪个图书馆,我不确定,有很多文章解释如何找到这个,但这是一件苦差事,可能需要一段时间,除非你很幸运。 memory profilers can give some idea. 内存分析器可以提供一些想法。

good explanation article 好的解释文章

-Xmx512m won't help you, because you are increasing the heap space. -Xmx512m对你没有帮助,因为你正在增加堆空间。 You are run out of PermGen space, not of heap space. 你的PermGen空间用完了,而不是堆空间。

Try to increase the PermGen space and put some flags for garbaging it. 尝试增加PermGen空间并放置一些标记来装饰它。 Here is more information: Recurring "PermGen" in Tomcat 6 以下是更多信息: Tomcat 6中的重复“PermGen”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM