[zeromq-dev] memory leak in PUB/SUB sockets

Daniel Sentenac sentenac at ego-gw.it
Fri Oct 1 17:44:58 CEST 2010


Hello,
Please find enclosed two files resulting from a  modified version of the 
original remote_th and local_th from zeromq-2.0.9 and recompiled in the 
same environment. We want to evidence here a problem where the sender 
has difficulties to manage the queue when receiver is slower to 
acknowledge the messages in PUB/SUB mode.

1) remote_th : a sender using bind socket in PUB mode. The sender send 
messages in a loop with  given size.
A pause is used to limit the frequency of messages sent (10 messages / sec)
2) local_th : a receiver using connect socket in SUB mode. The receiver 
receives messages in a loop from the sender. A pause is voluntarily used 
to slow down the receiver respect to the sender (5 messages / sec)
In these examples high_water_mark has been set to 1 on both client and 
server side.

I executed the process in the following way:
On a given Linux box:
 > ./remote_thr "tcp://eth0:3333" 100000

On another Linux box (or the same one gives the same result):
 > ./local_thr "tcp://<IPADDRESS>:3333"

I advise to check long term memory leaks with 'top' and for instant 
evolution using the command:
 > pmap -x <sender pid> | grep anon'

I observed the following from this test example :

1) if only one client is used, no memory leak is seen.
2) starting from two clients, an important memory leak is seen to occur 
on the sender side (You may see it well before half a minute with pmap). 
However no memory leaks is observed on client side.
3) If the same pause is used on receiver and sender sides, no memory 
leak is observed on sender side whatever number of clients used
4) The increase speed of the memory leak is not proportional to the 
number of clients and may appear with different strengths with the same 
configuration.  Indeed, the origin of the leak seems to come from a 
question of timing and synchronization between sender and receivers.

Hope it helps,

Cheers,

Daniel




-------------- next part --------------
A non-text attachment was scrubbed...
Name: local_thr.cpp
Type: text/x-c++src
Size: 3058 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20101001/8705d495/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: remote_thr.cpp
Type: text/x-c++src
Size: 2830 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20101001/8705d495/attachment-0001.cpp>


More information about the zeromq-dev mailing list