Rapid connect/disconnect with LINGER > 0 never releases memory

Description

Code to reproduce:

https://gist.github.com/848355

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:

1 2 3 4 5 6 7 client_task zmq_connect zmq::socket_base_t::connect zmq::create_pipe zmq::ypipe_t zmq::yqueue_t::yqueue_t() malloc

The call-tree for where 20% of the memory is malloc'ed is:

1 2 3 4 5 6 7 8 9 10 11 zmq::kqueue_t::worker_routine zmq::kqueue_t::loop zmq::zmq_listener_t::in_event zmq::zmq_init_t::zmq_init_t zmq::zmq_engine_t::zmq_engine_t zmq::decoder_t::decoder_t zmq::decoder_base_t::decoder_base_t malloc zmq::encoder_t::encoder_t zmq::encoder_base_t::encoder_base_t malloc

Environment

None

Status

Assignee

Unassigned

Reporter

chuckremes

Labels

None

Priority