Skip to content

Commit

Permalink
tsdb: zero out Labels pointers in pool
Browse files Browse the repository at this point in the history
So that memory is not kept alive for garbage-collection.

Signed-off-by: Bryan Boreham <[email protected]>
  • Loading branch information
bboreham committed Mar 5, 2024
1 parent 5d930ed commit 3776156
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tsdb/head_append.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
Expand Down Expand Up @@ -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])
}

Expand Down

0 comments on commit 3776156

Please sign in to comment.