[zeromq-dev] Pub/Sub with crashing subscribers - possible memory leak?

Samuel Lucas Vaz de Mello samuelmello at gmail.com
Tue Jul 2 15:09:41 CEST 2013

> > I have a simple PUB server that bind to an address and several SUB
> > clients that connect to it. It seems that memory is leaking at server as
> > clients connect/disconnect.
> With your test setup, I can make the memory leak go away by adding a
> zmq_poll() next to the sleep in pub.c.
> The background is that pipe termination works by sending commands
> between the io threads and the publisher socket. If the main thread just
> sleeps, the pub socket will never process these commands. Calling
> zmq_poll() triggers command processing. Many other calls - like sending
> messages - would do so as well and one usually doesn't have to worry
> about it.

Thanks, this solved the issue for me too.

In my scenario this socket is not frequently used (most of the messages use
another zmq sockets), so I think it's worth to include the pub socket in my
zmq_poll as well.

> The message topic mentions crashing subscribers. Maybe you need to make
> them crash to reproduce the issue?

Not really, sorry for the title.
When I started investigating I suspected that this was caused by
subscribers that didn't close the socket/context before leaving, but while
looking for the minimal test case to report I realized that it happened
even with sockets properly closed - then I forgot to update the title.

Thank you,

 - Samuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130702/9966d94f/attachment.htm>

More information about the zeromq-dev mailing list