Memory leak in certain instances at session.cpp:98
Description
Environment
None
Activity
Show:
Martin Sustrik October 26, 2011 at 11:50 AM
At decoder.cpp:124 the message is written to the pipe. The message is freed when it is retrieved from the pipe and sent to the wire.
At session.cpp:98 the new message is created, however, the old one still resides in the pipe and should be deallocated later on.
To solve this problem I need a minimal reproducible test case that I can use for debugging.
We're using jzmq with zeromq and XREP/XREQ sockets.
We were seeing a memory leak on our code that seemed to grow linearly with requests.
Valgrind reports this:
Looking what appears to be happening is that when the decoder is in message_ready (decoder.cpp:124), we call destination->write on the msg. This calls write on the pipe which never frees the message.
Then we hit session.cpp:98 which recalls zmq_msg_init, hereby losing the former contents of msg->content.
I can provide additional info if needed, but I suspect that session.cpp needs to call zmq_msg_close before it calls zmq_msg_init.