Add new bufferPool implementation

This commit is contained in:
Aditya Ujeniya
2026-02-27 14:44:32 +01:00
parent a418abc7d5
commit 07b989cb81
4 changed files with 155 additions and 4 deletions

View File

@@ -357,6 +357,9 @@ func Retention(wg *sync.WaitGroup, ctx context.Context) {
}
state.mu.Unlock()
// Clean up the buffer pool
bufferPool.Clean(state.lastRetentionTime)
}
}
})
@@ -425,6 +428,9 @@ func MemoryUsageTracker(wg *sync.WaitGroup, ctx context.Context) {
runtime.ReadMemStats(&mem)
actualMemoryGB = float64(mem.Alloc) / 1e9
bufferPool.CleanAll()
cclog.Infof("[METRICSTORE]> Cleaned up bufferPool\n")
if actualMemoryGB > float64(Keys.MemoryCap) {
cclog.Warnf("[METRICSTORE]> memory usage %.2f GB exceeds cap %d GB, starting emergency buffer freeing", actualMemoryGB, Keys.MemoryCap)