Never TLDR
Be rather careful on how to setup, load/unload and consume/destroy the supporting low-level data structures that the cool and powerful ZeroMQ
-library services rely on.
Otherwise, one has better to rather use the high-level companion functions.
Do not hesitate to read The Book - worth one's time
Pieter HINTJENS recommends in page 42, item 4:
To release (not destroy) a message, you call zmq_msg_close()
. This drops a reference, and eventually 0MQ will destroy the message.
In API documentation you may find even stronger caution:
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.
Applications should ensure that zmq_msg_close() is called
once a message is no longer required, otherwise memory leaks may occur.
Never access zmq_msg_t
members directly, instead always use the zmq_msg
family of functions.
Return value:
zmq_msg_close() function shall return zero if successful.
Otherwise it shall return -1 and
set errno to one of the values defined below.
Errors
EFAULT Invalid message.