[zeromq-dev] ZMQ allocating all available memory when sending
Clemens Lutz
lutzc at student.ethz.ch
Fri Nov 18 10:59:02 CET 2011
Hi,
I've been writing a benchmark to verify ZeroMQ's performance is near line-rate
on the machines I'm using. However, I keep running into the issue of ZMQ
allocating memory on the sender's side equal to the amount I'm sending. If I
want to send more data than I have physical memory the program will exit with
an "out of memory" error.
According to Valgrind everything should be fine concerning leaks. Setting
ZQM_HWM or ZMQ_RCVBUF doesn't seem to have any effect whatsoever.
Am I doing something wrong?
Here's an excert of the relevant code:
// setup
zmq::context_t* ctx;
zmq::socket_t* socket;
string address;
address = constructAddress(globalArgs->transportProtocol, globalArgs->host,
globalArgs->port);
ctx = new zmq::context_t(1);
socket = new zmq::socket_t(*ctx, ZMQ_DEALER);
socket->connect(address.c_str());
// run
unsigned int i;
// create a new message buffer
zmq::message_t msg(msgSize);
// send messages
for (i=0; i < numIter; i++) {
memset(msg.data(), 0, msgSize);
socket->send(msg);
msg.rebuild(msgSize);
}
// notify server of EOF
string strEOF = "EOF";
memset(msg.data(), 0, msgSize);
strEOF.copy((char *)msg.data(), strEOF.size());
socket->send(msg);
// clean up
socket->close();
delete socket;
delete ctx;
Thanks,
Clemens
More information about the zeromq-dev
mailing list