Closed teng231 closed 1 year ago
Could you share your configuration. Bigcache does not free once allocated memory to system.
func getConfig(config *BigCacheConfig) bigcache.Config {
return bigcache.Config{
// number of shards (must be a power of 2)
Shards: 16,
// time after which entry can be evicted
LifeWindow: 10 * time.Hour, // 5 * time.Minute,
// Interval between removing expired entries (clean up).
// If set to <= 0 then no action is performed.
// Setting to < 1 second is counterproductive — bigcache has a one second resolution.
CleanWindow: 5 * time.Minute,
// rps * lifeWindow, used only in initial memory allocation
MaxEntriesInWindow: 1000 * 10 * 60,
// max entry size in bytes, used only in initial memory allocation
MaxEntrySize: 100,
// prints information about additional memory allocation
Verbose: false,
// cache will not allocate more memory than this limit, value in MB
// if value is reached then the oldest entries can be overridden for the new ones
// 0 value means no size limit
HardMaxCacheSize: 500,
// callback fired when the oldest entry is removed because of its expiration time or no space left
// for the new entry, or because delete was called. A bitmask representing the reason will be returned.
// Default value is nil which means no callback and it prevents from unwrapping the oldest entry.
OnRemove: nil,
// OnRemoveWithReason is a callback fired when the oldest entry is removed because of its expiration time or no space left
// for the new entry, or because delete was called. A constant representing the reason will be passed through.
// Default value is nil which means no callback and it prevents from unwrapping the oldest entry.
// Ignored if OnRemove is specified.
OnRemoveWithReason: nil,
}
}
so in your example cache uses 400MB while max size it's 500MB. I think it's correct behavior.
so in your example cache uses 400MB while max size it's 500MB. I think it's correct behavior.
mem start with 90mb my data limit 2000 items but after 10 days increase 1gb
i setup limit resource on k8s pod will be restarted when memory equal 1GB. if not limit maybe can increase more
Go 1.19 introduced GOMEMLIMIT
maybe it's worth to use it. Although bigcache should not consume more memory then HardMaxCacheSize
there is still some room for underlying map and a chance that Go does not release once allocated memory.
What is the issue you are having?
What is BigCache doing that it shouldn't?
Environment:
/etc/os-release
or winver.exe):