Dealing with “java.lang.OutOfMemoryError: PermGen space” error



Dealing with “java.lang.OutOfMemoryError: PermGen space” error


1.问题描述:

         up vote 876 down vote favorite
370

Recently I ran into this error in my web application:

java.lang.OutOfMemoryError: PermGen space

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.

share | improve this question
 
 
I have fought this for hours, but I have no good news. See my related question:stackoverflow.com/questions/1996088/… You may still have a memory leak, e.g. classes are not garbage collected because your WebAppClassLoader is not garbage collected (it has an external reference that is not cleared). increasing the PermGen will only delay the OutOfMemoryError, and allowing class garbage collection is a precondition, but will not garbage collect classes if their class loader still has references to it. –  Eran Medan Jan 14 '10 at 11:48
 
I got this error at addingdisplay taglib. Removing so also solved the error. Why so? –  masT Nov 14 '13 at 11:51
 
And how did you run into it? –  Thorbjørn Ravn Andersen Feb 25 '14 at 4:16
5 
use JDK 1.8 :þ welcome to the MetaSpace –  Rytek Mar 20 '14 at 16:25


                    

2.解决方案

27 Answers 27

up vote 469 downvote accepted

The solution was to add these flags to JVM command line when Tomcat is started:

-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

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

where servicename is the name of the server as viewed in services.msc

Source: orx's comment on Eric's Agile Answers.




3.Win7系统下解决方案补充(由于新的问题):Unable to open the service ‘tomcat6w’

参考文章:http://www.programgo.com/article/61112223491/


4.参考资料:(1)http://stackoverflow.com/questions/88235/dealing-with-java-lang-outofmemoryerror-permgen-space-error

                     (2)https://plumbr.eu/outofmemoryerror/permgen-space




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值