[zeromq-dev] High memory usage (memory leak?)
Stefan de Konink
stefan at konink.de
Sun Jul 15 20:00:47 CEST 2012
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Hi,
We are using ZeroMQ 2.2 and are quite happy about it. We wish we could
move to ZeroMQ 3 but some outstanding bugs regarding the PubSub
implementation prevent this.
One of our current mysteries is the enormous high amount of memory our
pubsub uses. The clients on the other hand consume a very high virtual
memory amount. (Think in order of 500MB+)
It seems that once in a few weeks we end up with a:
FATAL ERROR: OUT OF MEMORY (yqueue.hpp:54)
Our source code is pretty simple - no mallocs from our side what so
ever and every init is closed; Still if I look to the virtual memory
and real memory of one of my clients I see:
146MB virtual
56256 real
...where is this memory spend?
Stefan
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <zmq.h>
int main (int argc, char *argv[]) {
if (argc != 3) {
printf("%s [receiver] [pubsub]\n\nEx.\n%s tcp://127.0.0.1:7807
tcp://127.0.0.1:7817\n", argv[0], argv[0]);
exit(-1);
}
void *context = zmq_init (1);
void *pubsub = zmq_socket (context, ZMQ_PUB);
void *receiver = zmq_socket (context, ZMQ_PULL);
zmq_bind (pubsub, argv[2]);
zmq_bind (receiver, argv[1]);
while (1) {
int64_t more;
size_t more_size = sizeof more;
do {
/* Create an empty 0MQ message to hold the
message part */
zmq_msg_t part;
int rc = zmq_msg_init (&part);
assert (rc == 0);
/* Block until a message is available to be
received from socket */
rc = zmq_recv (receiver, &part, 0);
assert (rc == 0);
/* Determine if more message parts are to
follow */
rc = zmq_getsockopt (receiver, ZMQ_RCVMORE,
&more, &more_size);
assert (rc == 0);
if (more) {
zmq_send (pubsub, &part, ZMQ_SNDMORE);
} else {
zmq_send (pubsub, &part, 0);
}
zmq_msg_close (&part);
} while (more);
}
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEAREKAAYFAlADBU4ACgkQYH1+F2Rqwn3iVwCeLZGRgTRVVHXVAL9smKLYnEbC
+LkAoIcWRhK1YylyLUlpkDEtoLgF0qiS
=Hy+T
-----END PGP SIGNATURE-----
More information about the zeromq-dev
mailing list