You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Tomas Lebovic (JIRA)" <ji...@apache.org> on 2006/09/22 10:44:23 UTC

[jira] Created: (AMQ-937) Memory Leak in Message transport / send / recieve C++ client

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

                 Key: AMQ-937
                 URL: https://issues.apache.org/activemq/browse/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. 

<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.



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira