Code to reproduce:
The code sets up a single SUB socket binding to a port. It then launches 4 client threads. Each thread creates a new PUB socket, connects, sends ONE message, and then closes the socket. It does this a few thousand times in a row and then stops.
When ZMQ_LINGER is set to 0, the memory being held by zmq_connect() is slowly released over the course of about 120 seconds. The program ran at around 90% cpu during this phase when every client was sleeping and the server SUB socket was maybe processing messages.
When ZMQ_LINGER is set to 1 (or above), the memory allocated by zmq_connect() is never released! CPU stays up around 80-90% but it doesn't appear to be doing anything.
The call-tree for where 70% of the memory is malloc'ed is:
The call-tree for where 20% of the memory is malloc'ed is: