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.

Reply via email to