You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
hashmapStats allocated unconditionally regardless of StatsEnabled #422
However, hashmapStats is only read/written when StatsEnabled: true. DefaultConfig sets StatsEnabled: false, so the vast majority of users never use stats — yet they pay the full memory cost of hashmapStats at startup.
Memory impact
The allocation cost per shard is initialShardSize() * sizeof(map entry). With DefaultConfig:
MaxEntriesInWindow = 600_000, Shards = 1024
initialShardSize = 600_000 / 1024 = 585 entries per shard
Each map pre-allocates ~17.5 KB of buckets
For a setup with many independent BigCache instances (e.g. 16), the unconditional hashmapStats allocation adds:
16 instances × 1024 shards × ~17.5 KB = ~286 MiB
This memory is entirely wasted when StatsEnabled: false.
Expected behavior
hashmapStats should only be allocated when StatsEnabled: true:
Allocate hashmapStats conditionally in initNewShard, and guard all reads/writes to it with a StatsEnabled check (they likely already are, given the field only makes sense with stats on).
Activity