question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory leak on disconnect() method usage with producer

See original GitHub issue

Hi,

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:closed
  • Created 4 years ago
  • Comments:18 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
iradulcommented, May 20, 2020

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 or offset_commit_cb are set and these need to be addressed as well.

1reaction
ArneSchulzecommented, May 26, 2020

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.

image

In comparison, this is the memory allocation timeline of our service running on the latest master.

memory-allocation-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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found