.NET Confluent Kafka consumer memory leak
up vote
2
down vote
favorite
We're seeing huge memory leaks when consuming from Kafka using the Confluent Kafka .NET library. One thing I've noticed is the code consumes without a using statement: while (true) { if (_consumer.Consume(out Message<string, string> message, TimeSpan.FromMilliseconds(100))) { OnMessage(message); } } However, that while loop runs for the lifetime for the application, so .Dispose() would never be called whilst consuming anyway. No other consumer instances are created. As the code behind the library is in C, will objects created by the library be cleaned if we call GC.Collect(), or is this unmanaged code which the garbage collector has no control over? Anything else which might be causing the leak, does consumer.Close() need to be called at certain periods