[zeromq-dev] question about message buffer

Mohit Jaggi mohitjaggi at gmail.com
Mon Mar 4 08:34:52 CET 2013

I am a little confused about how messages and buffers are handled in zmq.
In the following example, valgrind finds a message leak for 'm'.
1) Should I call delete for 'm' after the send?
2) zmq will keep the buffer(data) but free memory for 'm' if I do this?
3) What about 'topic'? It is on stack and data is small, so I guess it uses
the vsm area to store the message?
4) Will send for 'topic' make a copy of the data then?


string buf;


 message_t m = new message_t(buf.size());

 memcpy((*void**) m.data(), buf.c_str(), buf.size());

 string topic(string("X") + string("Y") + string("Z"));

publisher->send(topic.c_str(), topic.size(), ZMQ_SNDMORE); //topic

publisher->send(m); //data
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130303/85797440/attachment.htm>

More information about the zeromq-dev mailing list