activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eugene Rodos (JIRA)" <>
Subject [jira] Created: (AMQ-2838) Memory Leak when using ConnectionConsumer and a Persistent Broker
Date Mon, 19 Jul 2010 22:10:52 GMT
Memory Leak when using ConnectionConsumer and a Persistent Broker

                 Key: AMQ-2838
             Project: ActiveMQ
          Issue Type: Bug
          Components: Broker
    Affects Versions: 5.3.1
            Reporter: Eugene Rodos

I found a memory leak in ActiveMQ when using an embedded broker with persistence (enabled
by default) and using the connection to create a ConnectionConsumer.  The memory leak occurs
after performing the following steps:

1. acquire a Connection (ActiveMQConnection) from a ConnectionFactory (ActiveMQConnectionFactory)
2. use the Connection to create a ConnectionConsumer
3. close the ConnectionConsumer
4. close the Connection
5. repeat steps 1 and 4 from above

The memory leak is in org.apache.activemq.thread.Scheduler.  After the last connection is
closed, the embedded broker is shutdown.  When this happens all AMQ threads are killed except
for the "ActiveMQ Scheduler" thread.  This is a Timer that contains a queue of scheduled tasks.
 If no brokers are running, this queue should be empty.  In fact if persistence is turned
off on the broker, the queue is correctly emptied after the last connection is closed.  However,
with persistence on, the queue does not get emptied completely.

The memory leak is directly proportional to the number of ConnectionConsumers that are created
on the connection.  That is, the more ConnectionConsumers are created, the more tasks will
remain on the Scheduler's task queue after the connection is closed.

In our test environment, we create many ConnectionConsumer objects for each test and run many
such tests.  The memory leak accumulates quickly and we soon get an OutOfMemoryException.

I'm attaching a junit test that illustrates the problem.  The NUM_OF_CYCLES and NUM_OF_CONNECTION_CONSUMERS
constants can be increased to see how the memory leak grows with increased number of iterations
and ConnectionConsumer objects created, respectively.  Also, persistence can be turned off
on the broker url to see that the test succeeds in that case (i.e. no RAM leak).

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message