I would presume it does it so it can avoid allocating on the heap for small messages.
If your message is < 30 bytes then it is stored within message_t, i.e. on the stack if message_t is on the stack, >= 30 bytes it mallocs some memory (buffer size + sizeof(content_t) for some reference counting housekeeping). Richard. From: "Christoph Heindl" <[email protected]> To: "ZeroMQ development list" <[email protected]> Date: 14/02/2013 09:43 AM Subject: Re: [zeromq-dev] C++ Move Constructor and Assignment Operator Sent by: [email protected] Hi Richard, On Thu, Feb 14, 2013 at 10:14 AM, <[email protected]> wrote: I believe zeromq does this is by design. It copies the data if the message size is small and reference counts it if its above a certain size. Ok, I did not know that. Would by interesting to know why. Is ZMQ using some kind of small buffer optimization, where it uses the first few bytes of the buffer for reference counter or storing the values if small enough? It looks like the size threshold is specified by the max_vsm_size enum in msg.hpp, currently set to 29, so if you make your message size 30 it should switch to reference counting. I did and it works. Added both, positive and negative tests. Thanks for the hint. Best, Christoph_______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev =========================================================== The information in this email is confidential, and is intended solely for the addressee(s). Access to this email by anyone else is unauthorized and therefore prohibited. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited and may be unlawful. ===========================================================
<<inline: graycol.gif>>
_______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
