2

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?

EugeneP
  • 11,783
  • 32
  • 96
  • 142
  • More often than not that problem lies within the web application. It's rather easy to accidentally create a web application that *can't* be unloaded cleanly. – Joachim Sauer Jun 01 '10 at 11:34
  • @Joachim Sauer Well, it hangs up on deploy as well. – EugeneP Jun 02 '10 at 07:33
  • I've never seen Tomcat do that unless it's not configured correctly or the Web Application itself hangs during startup. Did you check with `jstack` to see at which point it hangs? – Joachim Sauer Jun 02 '10 at 10:25

2 Answers2

6

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:

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

Community
  • 1
  • 1
ewernli
  • 38,045
  • 5
  • 92
  • 123
4

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"
Tommi
  • 8,550
  • 5
  • 32
  • 51