Sam Parsons created AMQCPP-510:
----------------------------------

             Summary: Consumer leaks memory with checkForDuplicates=true
                 Key: AMQCPP-510
                 URL: https://issues.apache.org/jira/browse/AMQCPP-510
             Project: ActiveMQ C++ Client
          Issue Type: Bug
          Components: CMS Impl
    Affects Versions: 3.7.1, 3.7.0, 3.8.0
         Environment: Linux x86/64 (ubuntu)
            Reporter: Sam Parsons
            Assignee: Timothy Bish


The example application (examples/main.cpp) leaks memory in the consumer. 

To reproduce the problem, add a usleep(100000) after the producer->send, set 
useTopics = false and numMessages = 2000000.

With the following url, the example application remains on 4% CPU and 15 meg of 
memory on my development machine: 

"failover:(tcp://localhost:61616)?connection.checkForDuplicates=false" 

Without the "checkForDuplicates=false" the cpu and memory usage grows 
constantly. I eventually stopped it at 100% CPU and 340 meg of memory. 

Valgrind suggested that the leak was in ConnectionAudit.cpp:100. I added the 
following debug: 

try { 
  audit = this->impl->destinations.get(destination); 
} catch (NoSuchElementException& ex) { 
  audit.reset(new ActiveMQMessageAudit(auditDepth,auditMaximumProducerNumber)); 
  this->impl->destinations.put(destination, audit); 
  std::cout << "New destination audit: " << destination->toString() 
            << ", size: " << this->impl->destinations.keySet().size() << 
std::endl; 
} 

...and it prints... 

Sent message #410 from thread 140736021874568 
New destination audit: queue://TEST.FOO, size: 410 
Message #410 Received: Hello world! from thread 140736021874568 
Sent message #411 from thread 140736021874568 
New destination audit: queue://TEST.FOO, size: 411 
Message #411 Received: Hello world! from thread 140736021874568 

So the size of the destinations map keeps increasing. It seems to think every 
message has a new destination, but this is not the case. It's just the example 
code in main.cpp which creates the TEST.FOO destination and sends messages to 
it in a loop. 

I tested 3.7.0, 3.7.1 and 3.8.0 and the problem is in all of these versions. 
3.4.4 does not have this problem, but that version does not have duplicates 
detection so that's probably why.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to