tsdb: zero out Labels and memSeries pointers in pool (#13712)

* tsdb: zero out Labels and memSeries pointers in pool

So that the garbage-collector doesn't see this memory as still in use.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

---------

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Signed-off-by: Björn Rabenstein <github@rabenste.in>
Co-authored-by: Björn Rabenstein <github@rabenste.in>
This commit is contained in:
Bryan Boreham 2024-03-06 12:36:34 +00:00 committed by GitHub
parent 0eb39a604b
commit bbe39af99f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -229,6 +229,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])
}
@ -278,6 +281,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])
}