diff --git a/pkg/metricstore/buffer.go b/pkg/metricstore/buffer.go index 557a941c..2d752006 100644 --- a/pkg/metricstore/buffer.go +++ b/pkg/metricstore/buffer.go @@ -54,10 +54,6 @@ import ( // of data or reallocation needs to happen on writes. const BufferCap int = DefaultBufferCapacity -// maxPoolSize caps the number of buffers held in the pool at any time. -// Prevents unbounded memory growth after large retention-cleanup bursts. -const maxPoolSize = 4096 - // BufferPool is the global instance. // It is initialized immediately when the package loads. var bufferPool = NewPersistentBufferPool() @@ -101,10 +97,7 @@ func (p *PersistentBufferPool) Put(b *buffer) { p.mu.Lock() defer p.mu.Unlock() - if len(p.pool) >= maxPoolSize { - // Pool is full; drop the buffer and let GC collect it. - return - } + p.pool = append(p.pool, b) } diff --git a/pkg/metricstore/metricstore_test.go b/pkg/metricstore/metricstore_test.go index 9087df2a..35f97278 100644 --- a/pkg/metricstore/metricstore_test.go +++ b/pkg/metricstore/metricstore_test.go @@ -52,23 +52,6 @@ func TestBufferPoolClear(t *testing.T) { } } -// TestBufferPoolMaxSize verifies that Put() silently drops buffers once the -// pool reaches maxPoolSize, preventing unbounded memory growth. -func TestBufferPoolMaxSize(t *testing.T) { - pool := NewPersistentBufferPool() - for i := 0; i < maxPoolSize; i++ { - pool.Put(&buffer{data: make([]schema.Float, 0, BufferCap), lastUsed: time.Now().Unix()}) - } - if pool.GetSize() != maxPoolSize { - t.Fatalf("pool size = %d, want %d", pool.GetSize(), maxPoolSize) - } - - pool.Put(&buffer{data: make([]schema.Float, 0, BufferCap), lastUsed: time.Now().Unix()}) - if pool.GetSize() != maxPoolSize { - t.Errorf("pool size after overflow Put = %d, want %d (should not grow)", pool.GetSize(), maxPoolSize) - } -} - // ─── Buffer helpers ─────────────────────────────────────────────────────────── // TestBufferEndFirstWrite verifies the end() and firstWrite() calculations.