libzmq icon indicating copy to clipboard operation
libzmq copied to clipboard

subscriber and publisher show different situation with differet created way when they receive messages.

Open fengmao31 opened this issue 1 year ago • 1 comments

Please use this template for reporting suspected bugs or requests for help.

Environment

  • libzmq version (commit hash if unreleased): master
  • OS: ubuntu20.04

Issue description

I find subscriber and publisher show different situation with differet created way when they receive messages. I test the different situation that zmq publisher use stack or heap, while zmq recevier use stack

Experiment

publisher

when I use stack to create zmq::context_t and zmq::socket_t, zmq subscriber lost first messages from zmq publisher. byuQoytv1s image

when I use heap to create zmq::context_t and zmq::socket_t, zmq subscriber can get all messages from zmq publisher. 6R1IDZYVa8 image

subscriber

image

fengmao31 avatar Jun 29 '23 07:06 fengmao31

It is because in a huge while. the stack variable is created and destroyed repeatly. while the zmq::context_t *context and zmq::socket_t *publisher is not in the while. only the make _unique operating in the while.

But why repeatly make _unique looks like not realloc the momery?

fengmao31 avatar Jun 29 '23 11:06 fengmao31