activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tomas Lebovic (JIRA)" <>
Subject [jira] Created: (AMQ-937) Memory Leak in Message transport / send / recieve C++ client
Date Fri, 22 Sep 2006 08:44:23 GMT
Memory Leak in Message transport / send / recieve C++ client

                 Key: AMQ-937
             Project: ActiveMQ
          Issue Type: Bug
          Components: CMS (C++ client)
         Environment: Win XP, VC++ Version 8
            Reporter: Tomas Lebovic
            Priority: Critical

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. 


#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

	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 ;

		p<IConnection> connection  = factory->createConnection();
		session= connection->createSession();
	catch(ConnectionException &e)
        topic = session->getTopic("memory.leak") ;
        producer = session->createProducer(topic) ;
	consumer1 = session->createConsumer(topic) ;
	consumer1->setMessageListener( smartify(&list1) ) ;

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

        return 0;


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.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


View raw message