[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: tomcat java memory consumption



I would investigate your opencms project for memory leaks/retention. I've been running heavily used tomcats (I use tomcat for both my companies website and intranet) for many months on end without any undue memory consumption.

Here are some pointers that might help:

You might want to make sure your sessions are being timed out properly and that you have an event handler for session timeouts so that you can properly free up resources.

Also make sure that you don't have any member variables (static or dynamic) in any servlets that might be maintaining links to data. (It is easy to forget to delete entries from a HashMap for example.) State data should be maintained in sessions or the servlet context.

Make sure you don't store session-type information in the servlet context. Again HashMaps and other java.util.* classes make it easy to leave data hanging around.

To ensure your system doesn't run out of memory,  add something like
   CATALINA_OPTS="-Djava.awt.headless=true -Xmx1024m"
to limit the JVM to 1GB of ram. (I always use much smaller numbers, but not knowing your app, and seeying as you have plenty of memory on your system this seems like a reasonable limit.)

If tomcat grows bigger than the memory limit you provided, the problem most likely is the number of threads that are active. Limit the number of thread in /etc/tomcat4/server.xml. Look for the connector you are using and change the default maxProcessors="75" to something lower. Assuming you are on a single processor box, it really doesn't help performance to increase the number of threads that much. (Tomcat5 should have this fixed, I believe)

Anyway, I hope this information helps.  Good luck.

-Andrew Scherpbier

Fabian Lienert wrote:

dear list members,

on a debian cluster running an opencms project with tomcat 4.1.24 and j2sdk1.4.2
we are experiencing memory problems.

there are 2 GB of memory. after start of tomcat java memory use is growing and growing,
later, other running services like mysql is running out of memory.

we tried several versions of java, blackdown's, sun's and ibm's, configured
catalina.sh with serveral options to reduce java's memory use,
no effect.
limiting users memory use with ulimit has no effect either.

any pointer appreciated!







Reply to: