puzpuzpuz / xsync

Concurrent data structures for Go
Apache License 2.0
1.13k stars 40 forks source link

What is the behavior of pre-sized and un-sized map? #118

Closed ivanjaros closed 9 months ago

ivanjaros commented 9 months ago

Does sized map mean the size is fixed? Does unsized map shrink or will it keep growing?

What is the memory management/behavior here?

puzpuzpuz commented 9 months ago

Pre-sized map simply has pre-allocated hash table large enough to fit the given number of elements. Other than that, it grows/shrinks like a non-pre-size map.

Though, it might be a good idea is to treat the given size as the given size as the minimal allowed size for the map. This way deletion won't lead to redundant shrink/growth.