Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 7439 invoked from network); 2 Oct 2009 17:45:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Oct 2009 17:45:52 -0000 Received: (qmail 43028 invoked by uid 500); 2 Oct 2009 17:45:48 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 42980 invoked by uid 500); 2 Oct 2009 17:45:48 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 42969 invoked by uid 99); 2 Oct 2009 17:45:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Oct 2009 17:45:48 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of christian.stoeber@googlemail.com designates 209.85.219.211 as permitted sender) Received: from [209.85.219.211] (HELO mail-ew0-f211.google.com) (209.85.219.211) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Oct 2009 17:45:36 +0000 Received: by ewy7 with SMTP id 7so1136635ewy.41 for ; Fri, 02 Oct 2009 10:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=d+CUOa9eK2k3IhZ24rV+trjfCa8a5uyToL3fJzzx55A=; b=e/og1pDfnBW1wstTT/jcbPJbcznYCOx+reEiAUTXNVpy7whoNZfzWO14AHkPjtS3PT x9zAHrdoFEJH9Vk4qNvqeywntyo15EvGdIj/HMQSKFJJt9vu6dyFChiYVoG9HdV2uump dOPG5pwXbNG8/o/k6up+k+OwVX8kuxaI2x4mg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=OxNb8rN2/pCwINIiw7GFiM9kN3yLVorfBi0CY43E/flXkRe8o8O1uED+jSkQcBtTq9 wDOiRgyLw0gZgpjyPUp4byyos0bULg8//NGhVdrNhlwg8VJ99Z7aXFnpngwxVYoOkXpH spJD/aconF+RR0rkOmyH7lgKhf6lfeHOBBdGw= Received: by 10.210.95.3 with SMTP id s3mr3502389ebb.47.1254505515969; Fri, 02 Oct 2009 10:45:15 -0700 (PDT) Received: from ?192.168.7.27? (i59F55C72.versanet.de [89.245.92.114]) by mx.google.com with ESMTPS id 10sm370475eyd.13.2009.10.02.10.45.13 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 02 Oct 2009 10:45:15 -0700 (PDT) Message-ID: <4AC63C24.1080706@googlemail.com> Date: Fri, 02 Oct 2009 19:45:08 +0200 From: =?ISO-8859-15?Q?Christian_St=F6ber?= User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Memory behavior: Tomcat versus Jetty References: <4AC3616E.9030706@googlemail.com> <4AC36661.2070105@apache.org> In-Reply-To: <4AC36661.2070105@apache.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Tim, thanks for the hint with the BodyContent. Mark, thanks for your hint to take heap dump. On this morning the two Tomcat instances were using 200 MB more memory than the Jetty instances do. So I thought it's a good time to take a heap dump. In the heap histogram in jhat I saw a big difference between the BodyContentImpl (class org.apache.jasper.runtime.BodyContentImpl) counts: Jetty: 43 Tomcat: 768 Suspicious! I've take a look at this code and the first thing I've seen was, that since Jasper 2.1 BodyContents won't reset its buffer by default. (see BodyContentImpl.clear()). The second thing - what's responsible - is the change at org.apache.jasper.runtime.JspFactoryImpl. JspFactoryImpl in Jasper 2.1 now caches the PageContext-objects per thread. A PageContext-object have an array of BodyContents and so the memory the buffers of these BodyContents reserved will newer be freed until the thread will be stopped and garbage collected. Until today I were using the default connectors with the maxThreads parameter, which newer shutsdown a thread. So the BodyContent's buffer were growing and growing, because we have some tags which generates much output, and would never be cleared. Now I am using a separate thread pool (executor), which cleans up the pool when a thread is idle. And now the memory behavior is almost equal to Jetty. Christian Tim Funk schrieb: > If you use JSP tags where the JSP body does not directly stream but > needs buffered for the tag to finish processing it (using BodyContent) > - then tomcat will allocate and reuse these. If you are creating pages > with large body contents - this can take *A LOT* of memory. The > rational is to reuse these instead of letting them go to the GC. But > there is a way to not have tomcat reuse these. > > http://tomcat.apache.org/tomcat-5.5-doc/jspapi/javax/servlet/jsp/tagext/BodyContent.html > > > -Tim > > Christian St�ber wrote: >> Hello list, >> >> we are about to migrate our webserver cluster from Jetty 5.1.14 to >> Tomcat 6.0.20. Currently there are four servers in our cluster with >> simple load balancing and no session clustering. >> >> At the moment we are testing Tomcat on 2 nodes of our cluster (also >> no session clustering yet). 2 remains with Jetty. Same WAR file an >> the same environment. Our first test ends in an OutOfMemoryError >> after two days. The java vm of the Tomcat servers has the same memory >> parameters as the server with the Jetty: -Xmx512m. And no other >> special GC parameters. >> >> Apperently the Tomcat needs more memory than Jetty. >> >> So we are trying to give Tomcat more memory: -Xmx768m. After two days >> the Tomcat is still running fine. >> >> Obviously Tomcat needs just a little bit more memory than Jetty. >> After these two days we can state the following memory behavior. >> >> Node Mem used Mem reserved >> 1 TC 400m 530m >> 2 TC 350m 495m >> 3 J 230m 350m >> 4 J 290m 400m >> >> Averagely Tomcat is using round about 110m more memory than Jetty. >> But why? >> >> I have seen that the Tomcat DefaultServlet may cache content up to >> 10m per default. But that are only 10m. >> Are there some other things Tomcat may cache and Jetty does not? >> >> Do you have any experiences? >> >> Thanks in advance >> Christian >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org >> For additional commands, e-mail: users-help@tomcat.apache.org >> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org