Skip to content

Conversation

@shashank88
Copy link
Contributor

poll_batch currently leaks memory while initialising the queue
returned by rd_kafka_queue_get_consumer. The fix as suggested
by @mfontanini as done here is to initialise the queue with a
Queue so it's cleaned up when going out of scope.

vector<rd_kafka_message_t*> raw_messages(max_batch_size);
rd_kafka_queue_t* queue = rd_kafka_queue_get_consumer(get_handle());
ssize_t result = rd_kafka_consume_batch_queue(queue, timeout.count(), raw_messages.data(),
Queue queue(get_queue(rd_kafka_queue_get_consumer(get_handle())));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't actually fix the issue if someone's using rdkafka version < 0.11.5 (see the comment on get_queue). Maybe it's worth adding a comment saying that right above this line? e.g. "Note that this will leak the queue when using rdkafka < 0.11.5 (see get_queue comment)`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Squashed the comment to the same commit:
#107

poll_batch currently leaks memory while initialising the queue
returned by rd_kafka_queue_get_consumer. The fix as suggested
by @mfontanini as done here is to initialise the queue with a
Queue so it's cleaned up when going out of scope.
@mfontanini
Copy link
Owner

Thanks!

@mfontanini mfontanini merged commit df04b27 into mfontanini:master Jul 26, 2018
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

Successfully merging this pull request may close these issues.

3 participants