You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2009/11/30 22:31:14 UTC

svn commit: r885586 - /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp

Author: tabish
Date: Mon Nov 30 21:31:14 2009
New Revision: 885586

URL: http://svn.apache.org/viewvc?rev=885586&view=rev
Log:
Fix a potential memory leak when IndividualAck is used.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp?rev=885586&r1=885585&r2=885586&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp Mon Nov 30 21:31:14 2009
@@ -299,6 +299,19 @@
             // Stop and Wakeup all sync consumers.
             unconsumedMessages.close();
 
+            if( this->session->isIndividualAcknowledge() ) {
+                // For IndividualAck Mode we need to unlink the ack handler to remove a
+                // cyclic reference to the MessageDispatch that brought the message to us.
+                synchronized( &dispatchedMessages ) {
+                    std::auto_ptr< Iterator< Pointer<MessageDispatch> > > iter( this->dispatchedMessages.iterator() );
+                    while( iter->hasNext() ) {
+                        iter->next()->getMessage()->setAckHandler( Pointer<ActiveMQAckHandler>() );
+                    }
+
+                    dispatchedMessages.clear();
+                }
+            }
+
             // Remove this Consumer from the Connections set of Dispatchers
             this->session->disposeOf( this->consumerInfo->getConsumerId(), lastDeliveredSequenceId );