Memory leak on disconnect() method usage with producer
See original GitHub issueHi,
In one of our application we are using nodejs based microservice which internally uses node-rdkafka module to send messages using kafka producer which involves making runtime call scheduled at specific interval to perform below operations:
- Invoking kafka producer connect method
- Calling producer using kafka produce method to send messages
- Invoking kafka producer disconnect method
Disconnect method usage:
let prod = new Kafka.Producer({
// config properties
})
prod.disconnect()
However, we have been noticing memory leak when calling node-rdfafka producer and suspecting that it is disconnect method which is causing the leak.
Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:18 (2 by maintainers)
Top Results From Across the Web
Kafka off-heap memory leak - java
So the leak must be off-heap. Then I found this: [KAFKA-4741] - Memory leak in RecordAccumulator. append but it seems to be related...
Read more >- Finding memory leaks
The information shown here lets you quickly spot when the process is likely leaking memory. This is the best tool to use first...
Read more >Causes of Memory Leaks in JavaScript and How to Avoid ...
In this article, we will explore programming patterns that cause memory leaks in JavaScript and explain how to improve memory management.
Read more >KafkaProducer (kafka 2.3.0 API)
Failure to close the producer after use will leak these resources. The send() method is asynchronous. When called it adds the record to...
Read more >Introduction to librdkafka - the Apache Kafka C/C++ client ...
Lower buffering time leads to smaller batches and larger per-message overheads, increasing network, memory and CPU usage for producers, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve pushed preliminary fix on
fix-producer-leaks
branch. I still need help with testing. It would be great if some of you can try it out and see if it helps to prevent Producer memory leaks and also check if events are still flowing in as expected.Also, it seems that Consumer has leaks when
rebalance_cb
oroffset_commit_cb
are set and these need to be addressed as well.Hi @iradul, I just tried out your fix and it looks like the memory leak in
HighLevelProducer
is gone now! The memory allocation timeline of our service running with your fix shows a much cleaner heap.In comparison, this is the memory allocation timeline of our service running on the latest master.
The active objects allocated in the middle of the master graph are
HighLevelProducer
instances which should have already been garbage collected by the end of the recording