You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Graham Leggett <mi...@sharp.fm> on 2015/09/22 01:15:59 UTC

Qpid proton: pn_message and pn_message_free() - when are you expected to free the message?

Hi all,

In the example code for the async sending of messages below, the example is somewhat contrived in that it cleans up the pn_message structure after the whole messenger event loop has been shut down.

Obviously in a real application you want to send many messages, and you need to free those messages after sending them to stop leaking. When is the right time to free the messages? After the pn_messenger_put()? After pn_messenger_send()? Some other time?

https://qpid.apache.org/releases/qpid-proton-0.10/messenger/c/examples/send-async.c.html

Regards,
Graham
—


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Qpid proton: pn_message and pn_message_free() - when are you expected to free the message?

Posted by Bozo Dragojevic <bo...@digiverse.si>.
Hi Graham,

On 22. 09. 15 01.15, Graham Leggett wrote:
> Hi all,
>
> In the example code for the async sending of messages below, the example is somewhat contrived in that it cleans up the pn_message structure after the whole messenger event loop has been shut down.
>
> Obviously in a real application you want to send many messages, and you need to free those messages after sending them to stop leaking. When is the right time to free the messages? After the pn_messenger_put()? After pn_messenger_send()? Some other time?
>
> https://qpid.apache.org/releases/qpid-proton-0.10/messenger/c/examples/send-async.c.html

The example is actually correct. The call pn_messenger_put will encode
the pn_message and store that in messenger's store so the
pn_message structure is again available for use by the application.

Bozzo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Qpid proton: pn_message and pn_message_free() - when are you expected to free the message?

Posted by Graham Leggett <mi...@sharp.fm>.
On 22 Sep 2015, at 1:15 AM, Graham Leggett <mi...@sharp.fm> wrote:

> In the example code for the async sending of messages below, the example is somewhat contrived in that it cleans up the pn_message structure after the whole messenger event loop has been shut down.
> 
> Obviously in a real application you want to send many messages, and you need to free those messages after sending them to stop leaking. When is the right time to free the messages? After the pn_messenger_put()? After pn_messenger_send()? Some other time?
> 
> https://qpid.apache.org/releases/qpid-proton-0.10/messenger/c/examples/send-async.c.html

For the record, it turns out that you need to call pn_message_clear() before reusing a pn_message structure after sending it with pn_messenger_put(), otherwise qpid leaks.

Regards,
Graham
—


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org