3 ms·
The struct pointer itself wont be GC'd. It's intentional as the cache should be up for as long as the server process runs. However, that struct contains data t
by hu3 7y ago
The struct pointer itself wont be GC'd. It's intentional as the cache should be up for as long as the server process runs.
However, that struct contains data that can and will be GC'd once no longer used. This is the type of the variable: https://github.com/allegro/bigcache/blob/master/bigcache.go https://github.com/allegro/bigcache/blob/master/bigcache.go
- lainga 7y agoThe mantra I'm always told around slices is "Don't keep pointer slices. Don't keep pointer slices." Because the entire thing will fail escape analysis and go onto the heap. But it's OK in this case, right? Because, as you say, the BigCache (including the []*cacheShard) is allocated once; never gets GC'd; and it's around forever.