Skip to content

Commit

Permalink
fix memory leak on incor calc of cleanup bucket
Browse files Browse the repository at this point in the history
cleanup does not try to clean empty bucket
  • Loading branch information
flymedllva committed Dec 26, 2024
1 parent f9e778b commit 0507668
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ttl.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ func (m *expirationMap[V]) cleanup(store store[V], policy *defaultPolicy[V], onE
// (but not including) the last one that was cleaned up
var buckets []bucket
for bucketNum := m.lastCleanedBucketNum + 1; bucketNum <= currentBucketNum; bucketNum++ {
buckets = append(buckets, m.buckets[bucketNum])
// With an empty bucket, we don't need to add it to the Clean list
b := m.buckets[bucketNum]
if b == nil {
continue
}
buckets = append(buckets, b)
delete(m.buckets, bucketNum)
}
m.lastCleanedBucketNum = currentBucketNum
Expand Down

0 comments on commit 0507668

Please sign in to comment.