From c03e6a6c02b5e6c7d404b13e24e751d7d5c009a5 Mon Sep 17 00:00:00 2001 From: mhmtszr Date: Fri, 6 Jan 2023 17:54:25 +0300 Subject: [PATCH] Update kafka message pool to avoid unnecessary heap allocation --- kafka/producer/producer_batch.go | 1 + 1 file changed, 1 insertion(+) diff --git a/kafka/producer/producer_batch.go b/kafka/producer/producer_batch.go index a886870..263a16e 100644 --- a/kafka/producer/producer_batch.go +++ b/kafka/producer/producer_batch.go @@ -61,6 +61,7 @@ func (b *producerBatch) StartBatch() { case message := <-b.messageChn: b.messages = append(b.messages, *message) + KafkaMessagePool.Put(message) if len(b.messages) == b.batchLimit { err := b.FlushMessages() if err != nil {