Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-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 3A42193C9 for ; Fri, 4 Nov 2011 19:05:16 +0000 (UTC) Received: (qmail 42832 invoked by uid 500); 4 Nov 2011 19:05:15 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 42805 invoked by uid 500); 4 Nov 2011 19:05:15 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 42797 invoked by uid 99); 4 Nov 2011 19:05:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Nov 2011 19:05:15 +0000 X-ASF-Spam-Status: No, hits=3.0 required=5.0 tests=FORGED_YAHOO_RCVD,FREEMAIL_FROM,SPF_NEUTRAL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Nov 2011 19:05:09 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1RMP4K-0005cu-F3 for users@camel.apache.org; Fri, 04 Nov 2011 12:04:48 -0700 Date: Fri, 4 Nov 2011 12:04:48 -0700 (PDT) From: "Sergey C.(Vancouver)" To: users@camel.apache.org Message-ID: <1320433488459-4964951.post@n5.nabble.com> Subject: Possible memory leak in org.apache.activemq.pool.PooledSession MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hello Camel & ActiveMQ uses and developers! Here is our test setup and memory leak description. Using: -------- Spring Framework 3.0.5.RELEASE ActiveMQ 5.4.3 Camel 2.7.3 Test setup: --------------- There are 3 actors in our test: * ActiveMQ broker * Client process * Server process Client interacts with server using InOut pattern and static reply-to queue. Endpoint on the client side uri="jms:queue:Executor?deliveryPersistent=false&requestTimeout=3000&replyTo=Executor.Reply" Endpoint on the server side uri="jms:queue:Executor?&replyToDeliveryPersistent=false" How memory leak occurs: ====================== In this scenario Camel uses 'PersistentQueueReplyManager' to receive replies from the server process. Specifically it uses inner class 'PersistentQueueMessageListenerContainer' which is a child of 'DefaultMessageListenerContainer'. Factory method 'createListenerContainer()' in line 159 creates this inner class with cache level 'DefaultMessageListenerContainer.CACHE_SESSION' in line 193. So, method 'doReceiveAndExecute' in AbstractPollingMessageListenerContainer, line 277 creates ActiveMQMessageConsumer on each invocation ( AbstractPollingMessageListenerContainer, line 277 ) When consumer object is created PersistentQueueMessageListenerContainer has a reference to 'PolledSession', it calls method createConsumer in PooledSession, line 235. Object ActiveMQSession is wrapped inside PooledSession whic holds a list of created consumers. As a result reference to consumer object is stored inside both 'PooledSession' and inner session 'ActiveMQSession' Memory leak occurs when method 'doReceiveAndExecute' closes consumer in the finally section with JmsUtils.closeMessageConsumer(consumerToClose) in AbstractPollingMessageListenerContainer, line 365. ActiveMQMessageConsumer has a reference to ActiveMQSession object and detaches from it by calling this.session.removeConsumer(this); in line 775 But 'this.session' is a reference to ActiveMQSession object which is 'inner session' in this PooledSession wrapper. 'PooledSession' keeps holding references to all created ActiveMQMessageConsumer objects. In our test setup client with 512K heap chokes after ~200'000 request/replies. Workaround (for this scenario only): ================================ * comment line 323 in PooledSession ( //consumers.add(consumer); ) * recompile 'activemq-poll' module * install it into your local Maven repository * enjoy millions of request/replies without memory leak Please advice! Sergey C. -- View this message in context: http://camel.465427.n5.nabble.com/Possible-memory-leak-in-org-apache-activemq-pool-PooledSession-tp4964951p4964951.html Sent from the Camel - Users mailing list archive at Nabble.com.