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

Rick Flower nrf at ca-flower.com
Tue Jan 24 19:22:52 CET 2012

hi all.. I've got a question regarding the zero-copy stuff.. I've 
got a handful of threads that have messages that are not allocated 
per-se (or
may be taken from an STL vector behind the scenes).  These messages are 
be logged by a logging thread.  Currently the code (which does work by 
the way),
takes these messages to be logged (which are rather large), allocates a 
buffer with some housekeeping info and copies the passed-in data into 
allocated packet area prior to calling zmqsend to the logging thread.  
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 
the buffer may not be actually send (but would be queued) prior to the 
buffer disappearing for whatever reason AFTER the zmq send returned and 
processing performed by the thread that just finished logging that 
Does that seem reasonable?  I just want to make sure I'm not 
if I don't have to.. Thanks!

More information about the zeromq-dev mailing list