Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak with rd_kafka_conf_set_dr_msg_cb() #25

Open
chrislee87 opened this issue Nov 10, 2016 · 3 comments
Open

Memory leak with rd_kafka_conf_set_dr_msg_cb() #25

chrislee87 opened this issue Nov 10, 2016 · 3 comments

Comments

@chrislee87
Copy link

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

@zheolong
Copy link
Collaborator

没遇到过

@chrislee87
Copy link
Author

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

@zheolong
Copy link
Collaborator

看这个文件./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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants