[zeromq-dev] zmq_msg_t and zmq_msg_close() - lifetime of this structure

Ivan Pechorin ivan.pechorin at gmail.com
Mon Jan 9 20:06:15 CET 2012

2012/1/9 Marten Feldtmann <itlists at schrievkrom.de>:

> "The zmq_msg_close() function shall inform the ØMQ infrastructure that
> any resources associated with the message object referenced by msg are
> no longer required and may be released. Actual release of resources
> associated with the message object shall be postponed by ØMQ until all
> users of the message or underlying data buffer have indicated it is no
> longer required."
> I interpret it, that 0MQ still may reference this structure (located at
> message), but after finishing this function, the address of the
> structure may be not available any more .... therefore it may be
> overwritten.

In case of normal messages (*), zmq_msg_t stores just a pointer to a
reference-counted shared message buffer.

(*) by "normal" I mean larger than 29 bytes (see max_vsm_size in src/msg.hpp)
In case of VSM (very small messages), zmq_msg_t stores the data
inside, and it is copied around, not reference-counted.

See src/msg.hpp and src/msg.hpp, in particular zmq::msg_t::close ().

Use the source, Luke! :)

More information about the zeromq-dev mailing list