activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bish <tabish...@gmail.com>
Subject Re: The synchronous receive memory link
Date Mon, 02 Dec 2013 14:44:25 GMT
On 11/29/2013 02:18 PM, patlap wrote:
> Hello,
>
> I use the CMSTemplateReceiver.cpp example provided with active MQ. This
> class implement a simple synchronous receiver. (no onMessage Listener
> registered)
>
> BytesMessage* cmsMessage = (BytesMessage*)cmsTemplate->receive();
> if( cmsMessage ) {
>      printf( "%s received a message\n", cmsMessage->getBodyBytes() );
>      delete cmsMessage;
> }
>
> Each time the cmsMessage is deleted, the process always take more memory.
>
> The only difference with the example provided with activeMQ is I use a
> BytesMessage instead of a TextMessage.
>
> Thanks for help
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/The-synchronous-receive-memory-link-tp4674959.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Your code is leaking memory since the getBodyBytes method returns a copy 
of the contents of this message and you aren't destroying that data.

-- 
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.fusesource.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/


Mime
View raw message