patrickmn / go-cache

An in-memory key:value store/cache (similar to Memcached) library for Go, suitable for single-machine applications.
https://patrickmn.com/projects/go-cache/
MIT License
8.16k stars 874 forks source link

maps do not shrink after elements removal (delete) #110

Closed jiaoji100 closed 5 years ago

jiaoji100 commented 5 years ago

when I use delete map[somekey] in my code, I find that golang will not delete the key, but mark the key as empty instead.

Here are my questions: when a key was marked as empty, golang’gc will not free the memory? This map may cause memory leak, Is that reasonable?

patrickmn commented 5 years ago

I think this is more about Go's builtins than go-cache. It seems like there's a relevant issue here: https://github.com/golang/go/issues/20135