处理"java.lang.OutOfMemoryError:PermGen空间";错误 [英] Dealing with "java.lang.OutOfMemoryError: PermGen space" error
问题描述
最近我在Web应用程序中遇到此错误:
Recently I ran into this error in my web application:
java.lang.OutOfMemoryError:PermGen空间
java.lang.OutOfMemoryError: PermGen space
这是在Tomcat 6和JDK 1.6上运行的典型Hibernate/JPA + IceFaces/JSF应用程序. 显然,这可能是在重新部署了几次应用程序之后发生的.
It's a typical Hibernate/JPA + IceFaces/JSF application running on Tomcat 6 and JDK 1.6. Apparently this can occur after redeploying an application a few times.
是什么原因引起的,可以采取什么措施避免它发生? 我该如何解决该问题?
What causes it and what can be done to avoid it? How do I fix the problem?
推荐答案
解决方案是在启动Tomcat时将这些标志添加到JVM命令行:
The solution was to add these flags to JVM command line when Tomcat is started:
-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
您可以通过关闭tomcat服务,然后进入Tomcat/bin目录并运行tomcat6w.exe来执行此操作.在"Java"选项卡下,将参数添加到"Java选项"框中.单击确定",然后重新启动服务.
You can do that by shutting down the tomcat service, then going into the Tomcat/bin directory and running tomcat6w.exe. Under the "Java" tab, add the arguments to the "Java Options" box. Click "OK" and then restart the service.
如果收到错误消息指定的服务不存在,即为已安装的服务,则应运行:
If you get an error the specified service does not exist as an installed service you should run:
tomcat6w //ES//servicename
其中 servicename 是在services.msc中查看的服务器名称
where servicename is the name of the server as viewed in services.msc
来源:orx对 Eric的敏捷答案的评论.
Source: orx's comment on Eric's Agile Answers.
这篇关于处理"java.lang.OutOfMemoryError:PermGen空间";错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!