Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat on production server, PermGen and redeploys

Tags:

It looks like

 MemoryError: PermGen space
 java.lang.OutOfMemoryError: PermGen space

is a common problem. You can Increase the size of your perm space, but after 100 or 200 redeploys it will be full. Tracking ClassLoader memory leaks is nearly impossible.

What are your methods for Tomcat (or another simple servlet container - Jetty?) on production server? Is server restart after each deploy a solution?

Do you use one Tomcat for many applications ?

Maybe I should use many Jetty servers on different ports (or an embedded Jetty) and do undeploy/restart/deploy each time ?

like image 771
Piotr Gwiazda Avatar asked Aug 19 '10 11:08

Piotr Gwiazda


2 Answers

I gave up on using the tomcat manager and now always shutdown tomcat to redeploy.

We run two tomcats on the same server and use apache webserver with mod_proxy_ajp so users can access both apps via the same port 80. This is nice also because the users see the apache Service Unavailable page when the tomcat is down.

like image 68
Adam Butler Avatar answered Sep 23 '22 03:09

Adam Butler


You can try adding these Java options:

-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

This enables garbage collection in PermGen space (off by default) and allows the GC to unload classes. In addition you should use the -XX:PermSize=64m -XX:MaxPermSize=128m mentioned elsewhere to increase the amount of PermGen available.

like image 34
Soundlink Avatar answered Sep 26 '22 03:09

Soundlink