Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat 6 is really UNSTABLE when redeploying web apps

Do you know how to make it more stable, maybe properties to set, memory to allocate?

It always hangs up when redeploying web apps, thru manager (wars), web interface or maven plugin.

every second time it gives PermGenSpace, no memory errors etc.

on my local machine 3gb ram.

It looks like it should be manually set up to work in a stable way.

How to fix such a problem?

like image 918
EugeneP Avatar asked Nov 26 '25 21:11

EugeneP


2 Answers

PermGenSpace error happens because there's a memory leak during the undeploy/deploy cycle.

Undeploying an application should in theory not result in any memory leak, but it's a known issue that subtle dependencies between objects in different class loaders can cause memory leaks in app. server.

A short-term remedy is to configure the JVM memory (-Xms, -Xms, etc.) in a way that it doesn't blow after 2-3 redeployment but after many more, so that you need to restart Tomcat less frequently.

The long-term remedy would be to analyze what causes the memory leak. That's usually not a problem from Tomcat, neither the garbage collection, nor the application code, but rather the deployment of various libraries in different classloaders. A good article to understand this problem is:

  • Classloader leaks: the dreaded PermGen space exception

And here is a SO question that I suggest you look at, where the OP had a similar issue:

  • When and how is a java classloader marked for garbage collection?
like image 140
ewernli Avatar answered Nov 28 '25 11:11

ewernli


You need to increase the PermGenSpace, which may be too small for your needs by default. Startup Tomcat by giving this kind of switch to JVM:

-XX:MaxPermSize=256m

Also, you might want to increase the maximum heap size with this kind of switch:

-Xmx1g

You will need to test the settings a little to see which exact values are suitable for you.

These settings can be put into tomcat/bin/setenv.sh file, for example:

CATALINA_OPTS="-Xmx1g -XX:MaxPermSize=256m"
like image 22
Tommi Avatar answered Nov 28 '25 10:11

Tommi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!