Very small messages (under 30 bytes at present) are copied around rather than referenced.
-Pieter On Mon, Mar 11, 2013 at 8:04 AM, Mohit Jaggi <[email protected]> wrote: > Hmm...but messages are not sent in the context(I don't mean zmq context > here) of the calling thread, right? So, how can one use stack variable for > message object? > > > On Sun, Mar 10, 2013 at 11:08 PM, Pieter Hintjens <[email protected]> wrote: >> >> On Mon, Mar 11, 2013 at 12:39 AM, Mohit Jaggi <[email protected]> >> wrote: >> >> > I understand, but the caller does not control if the message is stored >> > in >> > VSM or on heap(since choice is made inside zmq code). So zmq has to >> > somehow >> > copy the VSM before the message variable goes out of scope. Just want to >> > confirm that zmq does that. >> > Or is it not OK to use zmq_msg_t on stack and it should always be >> > allocated >> > on heap? >> >> You're over-thinking it. The VSM data is just a property of zmq_msg_t >> like size and has the same scope / lifetime as the message object. >> >> You can use either stack or heap depending on your use case. >> >> -Pieter >> >> _______________________________________________ >> zeromq-dev mailing list >> [email protected] >> http://lists.zeromq.org/mailman/listinfo/zeromq-dev > > > > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev > _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
