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

Memory Leak in Message transport / send / recieve C++ client

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Won't Fix
    • None
    • None
    • Other C++ Clients
    • None
    • Win XP, VC++ Version 8

    Description

      There seems to be a memory leak in the message transport. If we take the following simple code below and then monitor memory consumption we will see it steadily go up.

      <code>

      #include <exception>
      #include <iostream>
      #include <map>
      #include <string>
      #include <stdio.h>
      #include <cms/IConnection.hpp>
      #include <cms/IConnectionFactory.hpp>
      #include <activemq/ConnectionFactory.hpp>
      #include <activemq/Connection.hpp>
      #include <ppr/TraceException.hpp>
      #include <ppr/net/Uri.hpp>
      #include <ppr/util/ifr/p>

      using namespace apache::activemq;
      using namespace apache::ppr::net;

      class TestAsynchTopic :public IMessageListener
      {
      private:

      public:
      void onMessage(p<IMessage> message)

      { p<IMapMessage> msg = p_dyncast<IMapMessage> (message) ; printf("got %s\n",msg->getString("msg")->c_str()); msg = NULL; }

      } ;

      char * bunk = "memory leak?";

      int main()
      {
      TestAsynchTopic list1;

      p<Uri> uri = new Uri("tcp://localhost:61616");
      p<ConnectionFactory> factory = new ConnectionFactory(uri);

      p<ISession> session = NULL;
      p<ITopic> topic = NULL ;
      p<IMessageConsumer> consumer1 = NULL;
      p<IMapMessage> message = NULL ;
      p<IMessageProducer> producer = NULL ;

      try

      { p<IConnection> connection = factory->createConnection(); session= connection->createSession(); }

      catch(ConnectionException &e)

      { printf("%s\n",e.what()); }

      topic = session->getTopic("memory.leak") ;
      producer = session->createProducer(topic) ;
      consumer1 = session->createConsumer(topic) ;
      consumer1->setMessageListener( smartify(&list1) ) ;

      while(1)

      { message = session->createMapMessage(); message->setString("msg", (char*)bunk); producer->send(message); message = NULL; }

      return 0;
      }

      </code>

      Now i haven't been using c++ api for a long time but i can't see any way to destroy the messages other then letting them go out of scope or when refrence count = 0. So if there is a way to destroy the messages after they are sent / recieved please let me know.

      Attachments

        Activity

          People

            Unassigned Unassigned
            tlebovic Tomas Lebovic
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: