I have the following code to declare a queue:<br><br>Connection connection = RabbitConnection.getConnection();<br>Channel channel = connection.createChannel();<br>channel.queueDeclare(getQueueName(), false, false, false, null);<br>consumer = new QueueingConsumer(channel);<br>channel.basicConsume(getQueueName(), true,consumer);<br><br>and the following to get the next Delivery object and process it:<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Delivery delivery = null;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; T queue = null;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //loop over, continuously retrieving messages<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; while(true) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; delivery = consumer.nextDelivery();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; queue = deserialise(delivery.getBody());<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; process(queue);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } catch (ShutdownSignalException e) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; logger.warn("Shutodwon signal received.");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } catch (ConsumerCancelledException e) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; logger.warn("Consumer cancelled exception: {}",e.getMessage());<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } catch (InterruptedException e) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; logger.warn("Interuption exception: {}", e);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br>If I run this with a queue containing a large number of objects, after approximatelly 2.7 million objects I get an out of memory exception.&nbsp; I found this originally by running it over night with data going in from JMeter at a rate ~90/s which at first it is consuming without any trouble, but in the morning I noticed a large number in RabbitMQ and an out of memory exception on the consumer.&nbsp; I ran it up again and used the Eclipse Memory Analyzer to determine where this memory was being used.&nbsp; From this I can see that the java.util.concurrent.LinkedBlockingQueue that is referenced by com.rabbitmq.client.QueueingConsumer is growing and growing until it runs out of memory.<br><br><p>Do I need to do anything to tell Rabbit to release resources?</p>

<p>I could increase the heap size but I'm concerned that this is just a 
short term fix and there might be something in my code that could bite 
me with a memory leak a few months into production deployment.</p>I have also posted this to StackOverflow:&nbsp; http://stackoverflow.com/questions/12687368/rabbitmq-queueingconsumer-possible-memory-leak<br>