From 3776156a8e3d2a1bf3a76ec790450892320396bb Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 5 Mar 2024 10:50:43 +0000 Subject: [PATCH] tsdb: zero out Labels pointers in pool So that memory is not kept alive for garbage-collection. Signed-off-by: Bryan Boreham --- tsdb/head_append.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tsdb/head_append.go b/tsdb/head_append.go index 149cd4666..7160711e5 100644 --- a/tsdb/head_append.go +++ b/tsdb/head_append.go @@ -243,6 +243,9 @@ func (h *Head) putExemplarBuffer(b []exemplarWithSeriesRef) { if b == nil { return } + for i := range b { // Zero out to avoid retaining label data + b[i].exemplar.Labels = labels.EmptyLabels() + } h.exemplarsPool.Put(b[:0]) } @@ -292,6 +295,9 @@ func (h *Head) getSeriesBuffer() []*memSeries { } func (h *Head) putSeriesBuffer(b []*memSeries) { + for i := range b { // Zero out to avoid retaining data + b[i] = nil + } h.seriesPool.Put(b[:0]) }