tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Tulley" <>
Subject RE: Tomcat Dies
Date Tue, 25 Nov 2003 22:28:28 GMT
  Sorry I'm late on this thread, I just noticed it.  Actually, I have
spent the whole last week or so chasing down some perceived memory leaks
on Tomcat (in general, not in my application), and maybe you are hitting
what I am hitting.

What kind of load is the server getting?

What I have seen is that if there is a reasonably heavy load for a
short amount of time, you can have too many sessions in memory that have
not yet hit their session timeout value, and so cannot be freed by the
garbage collector.  It is very easy to run out of memory well before
sessions start being let go.  As far as I can tell though, once the
sessions were freed, the memory itself cleared up.  (These comments
apply to 4.1.28 BTW)

Things you have in your control to solve this:

1) Make sure JSP's that do not deal with sessions have <%@ page
session="false" %> in them.  If not, then a session object is created in
every JSP, even if that JSP does not need it.

2) Define a <Manager> element for your context, and set the session
activity settings.  You CAN set maxActiveSessions, but the problem with
doing so is that your JSPs come up blank as soon as you hit your max
number of sessions, and continue to be blank until the sessions time
out.  So, you avoid an OutOfMemory and death, but you do not really
service ANY new requests / sessions after that point.

3) Set your session timeout to a lower value. (in conf/web.xml, or in
your application's web.xml)  I have not yet played with this.  It looks
like the default value is 30 minutes.  I was blowing up my server after
only 7-8 minutes (with -Xmx256m), so I was not coming close to the
timeouts.  A lower value, of course, could have a negative effect on
your user experience.

4) As it appears has been previously pointed out - higher memory
maximums.  I like to put it as high as possible and then see if the
memory settles down at some point, leading me to my actual maximum.  In
my case, where every request was creating a new session, a higher
maximum just stalled the problem, it did not solve it.

5) As it appears has been previously pointed out - play with GC.  I
haven't gotten this far myself.  But, from what I can see on how the GC
is acting, it is unable to free up the sessions, since they are still
valid and have real references to them.  I think playing with the new
1.4.x GC options would just make Tomcat be a little more stable as the
memory fills up if anything, it would not (in my case) avoid the
eventual death I was seeing.

>>> 11/25/03 12:21:38 PM >>>
Thanks for the reply.  Here is how I have the JAVA_OPTS set
-XX:+UseConcMarkSweepGC -XX:+PrintGCDetails") I wanted you to see this
incase there is a problem with the concurrent GC collector.  Also how
large of a Heap should we try?  We have 4 Gig with 3.5 free of RAM. 
last question if we higher the heap size won't that just mean it will
eventually die when it gets to that limit?

Thanks again,


Rob Wichterman

Systems Analyst

3996 Mount Royal Blvd.
Allison Park, PA 15101
Tel: 412-487-7424
Fax: 412-487-3355

-----Original Message-----
From: Shapira, Yoav [] 
Sent: Tuesday, November 25, 2003 1:27 PM
To: Tomcat Users List
Subject: RE: Tomcat Dies


>The Developers swear they do not use large collection objects.  I

Great.  Use a profiler to see for yourself where memory is allocated.

>noticed that the Garbage collection times start to get to be over a
>second or to before they die.  Another strange thing is that we have

So your heap is nearly full and big.  GC times of over a second are
by themselves a definitive indication that something is wrong.

>tomcat instances running on separate servers and they both die at the
>same time with the same error (Exception java.lang.OutOfMemoryError:
>requested 24 bytes forpromotion. Out of swap space?).  When I run top
>shows that there is over 14 Gig free of swap.  Is there a swap
>for tomcat?  \

There's no swap setting for tomcat, nor for Java, as that's not
something the JVM controls: it's an OS-level issue.  The requested for
promotion part means the JVM wanted to promote objects from the new
generation to the older one, but had no room.  

It could be that your apps are fine, there's no leak, and you just
to allocate more memory to the heap using the -Xmx parameter.

Yoav Shapira

>Any clues would be extremely helpful.
>-----Original Message-----
>From: Peter Guyatt [] 
>Sent: Monday, November 24, 2003 10:49 AM
>To: Tomcat Users List
>Subject: RE: Tomcat Dies
>Hi There,
>	It looks like there is a memory lieak in your code, do you have
>listeners, and if so are you storing the session objects in a
>not removing them from the collection when they are being
>-----Original Message-----
>From: Rob Wichterman [] 
>Sent: 24 November 2003 15:44
>To: 'Tomcat Users List'
>Subject: Tomcat Dies
>I have two tomcat instances each on a separate folder.  My problem is
>that after a few days we get one the following errors in Catalina.out
>1.	Exception java.lang.OutOfMemoryError: requested 24 bytes for
>promotion. Out of swap space?
>2.  SEVERE: Caught exception executing
>org.apache.jk.common.SocketConnection@18e8b78, terminating thread
>           java.lang.OutOfMemoryError
>Any help would be appreciated.

Jeff Tulley  (
Novell, Inc., The Leading Provider of Net Business Solutions

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message