Review and improve buffer pool implmentation. Add unit tests.

This commit is contained in:
2026-02-28 19:34:33 +01:00
parent 888d7fb235
commit 1ec41d8389
4 changed files with 566 additions and 40 deletions

View File

@@ -238,12 +238,13 @@ func (l *Level) forceFree() (int, error) {
// If delme is true, it means 'b' itself (the head) was the oldest
// and needs to be removed from the slice.
if delme {
// Nil out fields to ensure no hanging references
b.next = nil
b.prev = nil
b.data = nil
if cap(b.data) != BufferCap {
b.data = make([]schema.Float, 0, BufferCap)
}
b.lastUsed = time.Now().Unix()
bufferPool.Put(b)
l.metrics[i] = nil
}
}