[zeromq-dev] Question about the use of messages with allocated data (that gets freed)

Martin Sustrik sustrik at 250bpm.com
Wed Jan 25 05:05:06 CET 2012

On 01/25/2012 03:22 AM, Rick Flower wrote:

> I ran
> across, again, the paragraph in the guide talking about zero-copy and
> want to
> know if I omit the malloc/memcpy stuff if I'm going to get into trouble
> since
> the buffer may not be actually send (but would be queued) prior to the
> message
> buffer disappearing for whatever reason AFTER the zmq send returned and
> further
> processing performed by the thread that just finished logging that
> message..
> Does that seem reasonable?  I just want to make sure I'm not
> allocating/copying
> if I don't have to.. Thanks!

I am not sure what the actual question is. When using 
zmq_msg_init_data() and subsequend zmq_send() you most drop all the 
references to the buffer and supply 0MQ with a deallocation function 
that it calls when it is done with sending to deallocate the buffer.


More information about the zeromq-dev mailing list