diff --git a/collector/processor/concurrentbatchprocessor/batch_processor.go b/collector/processor/concurrentbatchprocessor/batch_processor.go index f166d61b..0aa2427f 100644 --- a/collector/processor/concurrentbatchprocessor/batch_processor.go +++ b/collector/processor/concurrentbatchprocessor/batch_processor.go @@ -375,12 +375,11 @@ func (b *shard) sendItems(trigger trigger) { ctx: b.pending[0].parentCtx, }) - // complete response sent so b.pending[0] can be popped from queue. - if len(b.pending) > 1 { - b.pending = b.pending[1:] - } else { - b.pending = []pendingItem{} - } + // Shift the pending array, to allow it to be re-used + // instead of re-allocated. + copy(b.pending[0:len(b.pending)-1], b.pending[1:]) + b.pending[len(b.pending)-1] = pendingItem{} + b.pending = b.pending[:len(b.pending)-1] } }