[zeromq-dev] Reduce zeromq memory usage?
Martin Sustrik
sustrik at 250bpm.com
Sat Oct 16 00:38:37 CEST 2010
Hi David,
> Can anyone offer advice on how to reduce zeromq's memory usage for an
> embedded app? I think zmq_init() uses the default stack size (8192 KB
> in Linux), which is a pretty big chunk when you've only got 64MB to work
> with(!) Does zeromq provide an API for controlling this, or is it
> better handled through OS mechanisms?
>
> Also, for tcp, the buffers corresponding to SO_SNDBUF and SO_RCVBUF are
> probably defaulting to their maximums (128K each, I think). For my app,
> each client has two sockets, so that could mean 2 * 2 * 128K, or half a
> meg per client. This could probably be decreased by an order of
> magnitude for my app, so... same question: can this be controlled via
> the API, or are there system calls I should make to do this?
>
Check ZMQ_SNDBUF and ZMQ_RCVBUF options which translate to underlying
SO_SNDBUF and SO_RCVBUF.
Also, have a look at src/config.hpp. in_batch_size and out_batch_size
define size of the internal 0MQ's buffers that it uses for batching
inbund/outbound data.
You may also find that tweaking some other options there (signaler's
SNDBUF size?) can reduce the overall amount of memory used.
> My simple pub/sub test client and server currently claim to be using 19%
> of available memory in 'top'. I've got to get this down in the range of
> 5-7% before I show my colleagues. (This is the reported usage for the
> app[s] I'm replacing.)
>
> Any advice much appreciated! And thanks to all who provided feedback on
> my 'make zeromq load faster' post. I've got a green light to go ahead
> and give it a try...
>
Nice!
Martin
More information about the zeromq-dev
mailing list