You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Robert Wille <to...@hotmail.com> on 2005/02/02 17:16:49 UTC

Memory leak in tomcat 5.0.28

I'm running tomcat 5.0.28 on Linux with JRE 1.4.2_04 and I seem to have a 
memory leak. I am not using Apache, but am using the Coyote connector. The 
server has been running under heavy load, being accessed by about 150 
computers running automated tests. I took heap snapshots about 8 and 20 
hours into the test using YourKit Java Profiler. When taking the snapshots, 
I first paused the system for several minutes, attempted to allocate more 
memory than was available to cause all collectable objects to be collected, 
and then took the snapshot. Therefore, the snapshots should contain very few 
collectable objects, and there should be very few open http connections. The 
following seems very suspicious:

The last snapshot shows 419 Http11Processor objects referencing 41M of 
memory. That is an increase of 232 Http11Processor objects.

It also shows 81,829 objects in the org.apache.tomcat.util.buf package, 
which reference 37M of memory. This is an increase of 44,874 objects.

The buffers and Http11Processor objects appear to be referenced by 
org.apache.tomcat.util.threads.ThreadWithAttributes. I show 425 instances, 
which is an increase of 225.

The first snapshot was 8 hours into the test, and in reality, I think the 
system should have reached steady state just a few minutes into the test. 
But I am obviously accumulating a lot of stuff.

Can somebody help?

Robert Wille

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Memory leak in tomcat 5.0.28

Posted by "Trond G. Ziarkowski" <tr...@gep-as.com>.
Thank you Robert!!

Just wanna say thanks alot for sharing all your findings with the rest 
of us. I start my tomcat 5.0.28 server with -ms252m -mx512m and it was 
running for about 3-4 days before i got the OutOfMemoryError. Since i 
removed the swallowOutput from my context, my server has'nt been over 
200m of used memory for 5 days!!

Once again thank you for finding this leak.

Regards

Trond


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Memory leak in tomcat 5.0.28

Posted by Filip Hanik - Dev <de...@hanik.com>.
feel free to open a bug report, so that this issue can be tracked.


----- Original Message -----
From: "Robert Wille" <to...@hotmail.com>
To: <to...@jakarta.apache.org>
Sent: Wednesday, February 02, 2005 1:25 PM
Subject: RE: Memory leak in tomcat 5.0.28


I've figured out my problem. I'm posting what I've discovered for the
benefit of others. The SystemLogHandler uses a map called logs where the key
is a ThreadWithAttributes and the value is a stack of CaptureLogs. The
problem is that when a thread dies, the ThreadWithAttributes object lives
forever because the map is never cleaned out. Threads come and go in the
thread pool, so stuff keeps accumulating there forever. You can prevent the
problem by turning off swallowOutput.

logs should be a ThreadLocal, not a map. That way the ThreadWithAttributes
objects can be collected (as well as the stack of CaptureLogs).

>From: "Robert Wille" <to...@hotmail.com>
>Reply-To: "Tomcat Users List" <to...@jakarta.apache.org>
>To: tomcat-user@jakarta.apache.org
>Subject: Memory leak in tomcat 5.0.28
>Date: Wed, 02 Feb 2005 09:16:49 -0700
>
>I'm running tomcat 5.0.28 on Linux with JRE 1.4.2_04 and I seem to have a
>memory leak. I am not using Apache, but am using the Coyote connector. The
>server has been running under heavy load, being accessed by about 150
>computers running automated tests. I took heap snapshots about 8 and 20
>hours into the test using YourKit Java Profiler. When taking the snapshots,
>I first paused the system for several minutes, attempted to allocate more
>memory than was available to cause all collectable objects to be collected,
>and then took the snapshot. Therefore, the snapshots should contain very
>few collectable objects, and there should be very few open http
>connections. The following seems very suspicious:
>
>The last snapshot shows 419 Http11Processor objects referencing 41M of
>memory. That is an increase of 232 Http11Processor objects.
>
>It also shows 81,829 objects in the org.apache.tomcat.util.buf package,
>which reference 37M of memory. This is an increase of 44,874 objects.
>
>The buffers and Http11Processor objects appear to be referenced by
>org.apache.tomcat.util.threads.ThreadWithAttributes. I show 425 instances,
>which is an increase of 225.
>
>The first snapshot was 8 hours into the test, and in reality, I think the
>system should have reached steady state just a few minutes into the test.
>But I am obviously accumulating a lot of stuff.
>
>Can somebody help?
>
>Robert Wille
>
>_________________________________________________________________
>Don’t just search. Find. Check out the new MSN Search!
>http://search.msn.click-url.com/go/onm00200636ave/direct/01/
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: Memory leak in tomcat 5.0.28

Posted by Robert Wille <to...@hotmail.com>.
I've figured out my problem. I'm posting what I've discovered for the 
benefit of others. The SystemLogHandler uses a map called logs where the key 
is a ThreadWithAttributes and the value is a stack of CaptureLogs. The 
problem is that when a thread dies, the ThreadWithAttributes object lives 
forever because the map is never cleaned out. Threads come and go in the 
thread pool, so stuff keeps accumulating there forever. You can prevent the 
problem by turning off swallowOutput.

logs should be a ThreadLocal, not a map. That way the ThreadWithAttributes 
objects can be collected (as well as the stack of CaptureLogs).

>From: "Robert Wille" <to...@hotmail.com>
>Reply-To: "Tomcat Users List" <to...@jakarta.apache.org>
>To: tomcat-user@jakarta.apache.org
>Subject: Memory leak in tomcat 5.0.28
>Date: Wed, 02 Feb 2005 09:16:49 -0700
>
>I'm running tomcat 5.0.28 on Linux with JRE 1.4.2_04 and I seem to have a 
>memory leak. I am not using Apache, but am using the Coyote connector. The 
>server has been running under heavy load, being accessed by about 150 
>computers running automated tests. I took heap snapshots about 8 and 20 
>hours into the test using YourKit Java Profiler. When taking the snapshots, 
>I first paused the system for several minutes, attempted to allocate more 
>memory than was available to cause all collectable objects to be collected, 
>and then took the snapshot. Therefore, the snapshots should contain very 
>few collectable objects, and there should be very few open http 
>connections. The following seems very suspicious:
>
>The last snapshot shows 419 Http11Processor objects referencing 41M of 
>memory. That is an increase of 232 Http11Processor objects.
>
>It also shows 81,829 objects in the org.apache.tomcat.util.buf package, 
>which reference 37M of memory. This is an increase of 44,874 objects.
>
>The buffers and Http11Processor objects appear to be referenced by 
>org.apache.tomcat.util.threads.ThreadWithAttributes. I show 425 instances, 
>which is an increase of 225.
>
>The first snapshot was 8 hours into the test, and in reality, I think the 
>system should have reached steady state just a few minutes into the test. 
>But I am obviously accumulating a lot of stuff.
>
>Can somebody help?
>
>Robert Wille
>
>_________________________________________________________________
>Don’t just search. Find. Check out the new MSN Search! 
>http://search.msn.click-url.com/go/onm00200636ave/direct/01/
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org