Hi,

I am trying to use CONFLATE on a sub socket, and noticed that if the messages are not "popped" off as they come, the memory of the program keeps increasing.

Here is a basic example:

PUB:

   #include <czmq.h>

   int main(){
        zsock_t *pub = zsock_new(ZMQ_PUB);
        zsock_bind(pub, "%s", "tcp://127.0.0.1:49152");
        while(!zsys_interrupted){
            zsock_send(pub, "8", zclock_time(), NULL);
        }
        zsock_destroy(&pub);
   }


SUB:

   #include <czmq.h>
   #include <stdio.h>
   int main(){
        zsock_t *sub = zsock_new(ZMQ_SUB);
        zsock_set_conflate(sub, 1);
        zsock_set_subscribe(sub, "");
        zsock_connect(sub, "%s", "tcp://127.0.0.1:49152");

        int64_t time;
        char *line = (char*)malloc(11);
        size_t len = 10;

        while(!zsys_interrupted){
            getline(&line, &len, stdin);
            if(zsock_recv(sub, "8", &time, NULL)==0){
                printf("%ld\n", time);
            }
        }
        zsock_destroy(&sub);
        return 0;
   }


So in the above example, the PUB program runs as fast as possible, sending out the system time.

The SUB program sets CONFLATE, so only the most recent timestamp is available. But, it only reads the socket after ENTER is pressed in the console. So the system memory skyrockets, even though I thought CONFLATE should be dropping old messages. Does this mean the old messages are not also freed? Is there something obvious I am missing here? I've racked my brain all afternoon and morning today, so I greatly appreciate any help here ...


Thanks


Kevin

_______________________________________________
zeromq-dev mailing list
[email protected]
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to