ZeroMQ is Nearing Release of 2.1
I've found a singular problem with ZeroMQ, and noted in the IRC chat conversations that this should be fixed in the soon-to-be-released 2.1. It's a simple memory leak with the sending of messages. My code is pretty simple: I get the payload for the message, I get the ZMQ socket it needs to be sent on, and then I simply make a ZMQ message and send it. That's about as simple as you can get:
if (aTopic.first() != NULL) { try { // lock up this socket while we send the data out... boost::detail::spinlock::scoped_lock lock(aTopic.second()); // make a ZMQ message of the right size zmq::message_t msg(aPayload.size()); // ...copy in the data we need from the payload memcpy(msg.data(), aPayload.data(), aPayload.size()); // ...and WHOOSH! out it goes aTopic.first()->send(msg); } catch (std::exception & e) { error = true; cLog.error("[sendToZMQ] trying to send the data got an " "exception: %s", e.what()); } }
If I comment out line 10 - the send(), the memory doesn't grow any faster than I might expect based on the cached messages. But leave it in and the memory grows and grows. More interestingly, it's different for the different kinds of payloads I send. Very odd.
Anyway... the ZeroMQ guys said they planned on having a release last week, but it seems things happened, and that's OK with me - this is important. I need to keep the memory under control.