camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Possible memory leak in org.apache.activemq.pool.PooledSession
Date Thu, 10 Nov 2011 10:52:31 GMT
Hi

I had a look and have also reproduced the leak in the AMQ pool.

In Camel 2.9 you can use replyToType=Exclusive, which would then not
have this leak.
As the consumer is cached once in the DMLC, and not needed to be
created on polls.
Also if using Exclusive, the performance is faster.

The caveat is that you cannot share the same queues for other replyTo
routes in Camel.
It must be exclusive.


The leak is possible to be fixed on the AMQ side, I will keep looking into this.



On Fri, Nov 4, 2011 at 8:04 PM, Sergey C.(Vancouver)
<sergey_chuykov@yahoo.com> wrote:
> 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.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message