Berek Bryan
Berek Bryan

Reputation: 14725

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

Upvotes: 19

Views: 37898

Answers (6)

Ganesh Tripathi
Ganesh Tripathi

Reputation: 31

try this : IN Linux Machines

export JAVA_OPTS="-XX:PermSize=128m"

Upvotes: 3

opyate
opyate

Reputation: 5428

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

Upvotes: 13

Fun With Puzzles
Fun With Puzzles

Reputation: 21

I agree that increasing the permgen space with -XX:MaxPermSize just delays the problem. I tried increasing the permgen and after that I started getting the same error after I sent more number of requests to my server. Additional flags like -XX:+CMSClassUnloadingEnabled is suggested even though it will decrease the performance little bit.

Upvotes: 2

Theresa Forster
Theresa Forster

Reputation: 1932

I have seen lots of permgen errors when tomcat is reloaded after a code change when using hibernate and spring, I think its due to the logger/ehcache instances not being shut down properly.

Upvotes: 1

kdgregory
kdgregory

Reputation: 39606

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)

Upvotes: 25

Faisal Feroz
Faisal Feroz

Reputation:

I think you might have many JSPs in your application. There is a known issue in tomcat where restarting a deployed application with many JSPs causes PermGen issues because tomcat recompiles and reloads all these classes again. Increasing the size as mentioned in the previous post should help.

Upvotes: 2

Related Questions