Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recurring "PermGen" in Tomcat 6

I keep getting a "PermGen" error on my Tomcat 6 server.

I know what application is causing the problem, but I am not sure why it is doing so. The application is using MySQL 5 and running on JDK 6.

Are there any tools/suggestions to diagnosis or analyze the underlying issue(s) with the specific application?

Thanks

like image 626
Berek Bryan Avatar asked Jan 23 '09 14:01

Berek Bryan


People also ask

How to avoid PermGen space error in Tomcat?

Solution. By default, Tomcat is assigned a very little PermGen memory for the running process. To fix it, increase the PermGen memory settings by using the following Java VM options. -XX:PermSize<size> - Set initial PermGen Size.

What is the use of PermGen space?

The PermGen area of the Java heap is used to store metadata such as class declarations, methods and object arrays. Therefore, the PermGen size requirements depend on the number of classes and methods as well as their size. Java memory is separated into different regions - Young, Tenured and PermGen.

How do I increase PermGen space in Weblogic?

To set PermGen size you can use e.g. -XX:PermSize=512m -XX:MaxPermSize=512m . Regarding Weblogic, set the JAVA_OPTIONS and see if these options are properly passed in as parameters into your Java process. You can also directly set these parameters in the startWeblogic.


2 Answers

The PermGen is used to store class definitions and the interned string pool. Your code could be filling it (if it calls intern needlessly), but more likely is that the default is undersized for your application.

This is because Tomcat will load new classes every time you deploy a WAR -- or, if you are working in a development environment, every time you edit a JSP. Those should eventually get cleaned up, but in an active development environment you can have periods where there are both old and new instances loaded. Or, if you're in a production environment and have a large web-app, you might simply need more space.

To set the permgen size, use -XX:MaxPermSize=SIZE

The following links may be helpful: tuning GC (this is the 1.5 edition), GC FAQ (1.4.2 edition), Hotspot VM options (I believe this is 1.6)

like image 124
kdgregory Avatar answered Oct 08 '22 04:10

kdgregory


Try the following JVM switches:

-XX:+UseConcMarkSweepGC
-XX:+CMSPermGenSweepingEnabled
-XX:+CMSClassUnloadingEnabled

Upping the permgen space with -XX:MaxPermSize just delays the problem.

Please see this comment: How to deal with “java.lang.OutOfMemoryError: PermGen space” error

That indirectly pointed me to these two posts: problem, solution

like image 41
opyate Avatar answered Oct 08 '22 05:10

opyate