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

active oldest votes
up vote 469 down vote 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





你可能感兴趣的:(exception,javaweb,memory,out,of)