ZeroMQ is Nearing Release of 2.1

ZeroMQ

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:

  1. if (aTopic.first() != NULL) {
  2. try {
  3. // lock up this socket while we send the data out...
  4. boost::detail::spinlock::scoped_lock lock(aTopic.second());
  5. // make a ZMQ message of the right size
  6. zmq::message_t msg(aPayload.size());
  7. // ...copy in the data we need from the payload
  8. memcpy(msg.data(), aPayload.data(), aPayload.size());
  9. // ...and WHOOSH! out it goes
  10. aTopic.first()->send(msg);
  11. } catch (std::exception & e) {
  12. error = true;
  13. cLog.error("[sendToZMQ] trying to send the data got an "
  14. "exception: %s", e.what());
  15. }
  16. }

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.