Skip to content

Commit 56fecc1

Browse files
committed
updates
1 parent bdc76f0 commit 56fecc1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

block/internal/cache/generic_cache.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ func NewCacheWithConfig[T any](config CacheConfig) (*Cache[T], error) {
9191
return nil, fmt.Errorf("failed to create daIncluded cache: %w", err)
9292
}
9393

94-
hashByHeightCache, err := lru.New[uint64, string](config.ItemsCacheSize)
94+
// hashByHeight must be at least as large as hashes cache to ensure proper pruning.
95+
// If an entry is evicted from hashByHeight before hashes, the corresponding hash
96+
// entry can no longer be pruned by height, causing a slow memory leak.
97+
hashByHeightCache, err := lru.New[uint64, string](config.HashesCacheSize)
9598
if err != nil {
9699
return nil, fmt.Errorf("failed to create hashByHeight cache: %w", err)
97100
}

0 commit comments

Comments
 (0)