zeromq / libzmq

ZeroMQ core engine in C++, implements ZMTP/3.1
https://www.zeromq.org
Mozilla Public License 2.0
9.45k stars 2.34k forks source link

Small memory leak with 4.3.4 from get_buffer #4694

Open dembekadam opened 3 weeks ago

dembekadam commented 3 weeks ago

Issue description

We use zmq PUB SUB sockets to have allocations in Kubernetes pods to communicate with each other over TCP. We usually send several messages per second.

When monitoring pod size and RSS of our application we see small increase every few hours. around 2-3 MB per day. We have a wrapper for memory allocation build in that monitor each memory allocation and free with stack trace similar to tools like valgrind.

Evey few hours it reports possible leak from

/3rdparty/build_3rd_party_libraries_rocky8/Zmq/source/src/decoder.hpp:72 _ZN3zmq20stream_engine_base_t17in_event_internalEv /3rdparty/build_3rd_party_libraries_rocky8/Zmq/source/src/stream_engine_base.cpp:280 _ZN3zmq20stream_engine_base_t13restart_inputEv /3rdparty/build_3rd_party_libraries_rocky8/Zmq/source/src/stream_engine_base.cpp:461 _ZN3zmq14session_base_t15write_activatedEPNS_6pipe_tE /3rdparty/build_3rd_party_libraries_rocky8/Zmq/source/src/session_base.cpp:332 _ZN3zmq11io_thread_t8in_eventEv /3rdparty/build_3rd_party_libraries_rocky8/Zmq/source/src/io_thread.cpp:91

The issue seams similar to https://github.com/zeromq/libzmq/issues/2830 but leak is only observer few times a day and not for each message.

Environment

Minimal test code / Steps to reproduce the issue

What's the actual result? (include assertion message & call stack if applicable)

Small increase in process RSS size continues to grow for 30 days in row .

What's the expected result?

No memory leak