开发者

Tomcat 6 is really UNSTABLE when redeploying web apps

开发者 https://www.devze.com 2023-01-01 12:42 出处:网络
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.

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?


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?


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"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号