Uploaded image for project: 'ActiveMQ C++ Client'
  1. ActiveMQ C++ Client
  2. AMQCPP-510

Consumer leaks memory with failover and checkForDuplicates=true

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.7.0, 3.7.1, 3.8.0
    • 3.8.1, 3.9.0
    • CMS Impl
    • None
    • Linux x86/64 (ubuntu)

    Description

      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.

      Attachments

        Activity

          People

            tabish Timothy A. Bish
            sparso Sam Parsons
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: