You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Timothy Bish <ta...@gmail.com> on 2013/12/02 15:44:25 UTC

Re: The synchronous receive memory link

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/