From users-return-31347-apmail-activemq-users-archive=activemq.apache.org@activemq.apache.org Fri Jul 20 09:49:01 2012 Return-Path: X-Original-To: apmail-activemq-users-archive@www.apache.org Delivered-To: apmail-activemq-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 16DE4D81F for ; Fri, 20 Jul 2012 09:49:01 +0000 (UTC) Received: (qmail 32813 invoked by uid 500); 20 Jul 2012 09:49:00 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 32679 invoked by uid 500); 20 Jul 2012 09:49:00 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 32663 invoked by uid 99); 20 Jul 2012 09:49:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jul 2012 09:49:00 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of gary.tully@gmail.com designates 74.125.82.171 as permitted sender) Received: from [74.125.82.171] (HELO mail-we0-f171.google.com) (74.125.82.171) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jul 2012 09:48:55 +0000 Received: by weyx43 with SMTP id x43so2621613wey.2 for ; Fri, 20 Jul 2012 02:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=kwcgKkLPjUDkraA8dpM5y1xZ2F/Y9wCq9c1mSjhSW08=; b=y2IL4IjcNmDKa55OW8FXAxq0EBdijRLu6lkK+1XLwMTf3iBLBLKdiqogj4X1gzclFM +nbSdQbaJ3aaUOZBBgfxL5ulJiKJOlADLya2k2fxYAV/u6s+vIOOysoGmkStvEyJE67I xJXxwZoW7MBgsNtajheMg0S71FJXlcnarc1HrfTT231sH3K2ryQD8PZuUnoPIEA7xb0F GEzkpTPDbqHrWP73hPIjj0JmbZDYYOxIyuTEHiMOQsbsGH5C/3qXUqhp6/yJ4tJz4NU5 +WhC5TJKbTMENovmt65An9RupGsaxCuNGNCJOTgkgmR0Ke9oKP3Zp+17NNrzka0MFYW5 j3ZA== MIME-Version: 1.0 Received: by 10.180.14.8 with SMTP id l8mr12744153wic.6.1342777713976; Fri, 20 Jul 2012 02:48:33 -0700 (PDT) Received: by 10.194.54.66 with HTTP; Fri, 20 Jul 2012 02:48:33 -0700 (PDT) In-Reply-To: <1342752097013-4654187.post@n4.nabble.com> References: <1342166981857-4653959.post@n4.nabble.com> <1342523219578-4654084.post@n4.nabble.com> <1342589532249-4654109.post@n4.nabble.com> <1342752097013-4654187.post@n4.nabble.com> Date: Fri, 20 Jul 2012 10:48:33 +0100 Message-ID: Subject: Re: [Old issue] Memory leak after stop web application in Tomcat From: Gary Tully To: users@activemq.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org connection pool stop needs to be called before the static shutdown methods. Because stop is called via a destroy-method, you must only call the static shutdowns from your shutdown bean, and only after the connection pool has stopped. So there should be a depends-on relation between the beans (shutdown depends on pool). I think they will be stopped in reverse order. Every call to close results in a call to stop on the inactivity monitor which tracks the inactivity monitor executor and calls shutdown when the reference count drops. Looking at it now, it may be that it needs to call java.util.concurrent.ThreadPoolExecutor#shutdownNow for that case where some tasks are executing. On 20 July 2012 03:41, liny wrote: > Thanks, Gary. > > I created a bean like you said: > > And added it to context xml: > > > If I don't call static shutdown() in MainApplication#stop(), like below: > > > After manual stop web app from Tomcat web manager, the memory leaks still > are there. Logs as below: > > you can see the AbstractInactivityMonitor is still running. > > If I call static shutdown() in MainApplication#stop(), and also in > MyDisposableBean, logs look different: > > > After double call static shutdown(), > thread [writeCheck] is gone after "java.lang.ClassNotFoundException: > org.apache.activemq.transport.AbstractInactivityMonitor$3". > Thread [InactivityMonitor ReadCheck] and [ActiveMQ Transport: > tcp://foo/15.87.14.93:61616] are still there, but after few seconds, they > are gone around 10:06:44.170 finally. > At the end, FailoverTransport even tried to reconnect...weird. > > I hope there is better solution on this issue. > Thank you again, Gary. > > -- > View this message in context: http://activemq.2283324.n4.nabble.com/Old-issue-Memory-leak-after-stop-web-application-in-Tomcat-tp4653959p4654187.html > Sent from the ActiveMQ - User mailing list archive at Nabble.com. -- http://fusesource.com http://blog.garytully.com