Qihoo360/logkafka

Memory leak with rd_kafka_conf_set_dr_msg_cb()

chrislee87 opened this issue · 3 comments

在producer中如果使用rd_kafka_conf_set_dr_msg_cb设置回调函数msgDelivered2会导致内存泄露,在测试中遇到过这种情况吗?

没遇到过

调用rd_kafka_produce_batch(rkt, partition, RD_KAFKA_MSG_F_FREE, rkmessages, msgcnt),写kafka失败时不需要释放内存吗?callback里没做处理,我测试时内存泄漏了。

看这个文件./src/logkafka/producer.cc ,有释放空间的语句

     /* Note: librdkafka will duplicate the key once more,
      * so we can free the original one after producing*/
     for (i = 0 ; i < msgcnt ; ++i) {
         free(rkmessages[i].key);
     }

     free(rkmessages);