Hi,
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?

Mohit.


string buf;

myObject.SerializeToString(&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
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to