Hi I'm trying to send large packets with ZeroMQ using the ventilator/worker/sink pattern.
I try adding workers. Each time, the sink process memory usage increases a little. Then it reaches a tipping point at about 6 or 7 workers where suddenly memory increases exponentially until it dies with:
> *** error: can't allocate region
> *** set a breakpoint in malloc_error_break to debug Assertion failed: (msg_->flags | ZMQ_MSG_MASK) == 0xff (zmq.cpp:211)
> Python(42410,0xaccb8a28) malloc: *** mmap(size=3559424) failed (error
> code=12)
Here is the code (showing only the worker/sink pattern):
import sys
import resource
import zmq
import time
context = zmq.Context()
if sys.argv[1] == 'worker':
# Socket to send messages to
sender = context.socket(zmq.PUSH)
sender.connect("tcp://localhost:5558")
while True:
msg = 'x' * 3559333
time.sleep(.01)
sender.send(msg)
else:
# Socket to receive messages on
receiver = context.socket(zmq.PULL)
receiver.bind("tcp://*:5558")
while True:
msg = receiver.recv()
print msg[0:5], len(msg), resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
Is this simply a lack of hardware resources? A backlog of data? Or is there a way of avoiding this?
I'm running OSX Mountain Lion with 16gb memory and Python 2.7 with zmq 2.2.0.1.
Thanks