greg7mdp / parallel-hashmap

A family of header-only, very fast and memory-friendly hashmap and btree containers.
https://greg7mdp.github.io/parallel-hashmap/
Apache License 2.0
2.53k stars 239 forks source link

Is phmap exception safe? #189

Closed yiguolei closed 1 year ago

yiguolei commented 1 year ago

I am using phmap to implement some operators like CountDistinct in Apache Doris. But I am using our database's own allocator to allocate memory. The allocator will throw exception if memory not sufficient in order to cancel the query to avoid OOM.

I am not sure if phmap is exception safe. For example, if throws exception during call phmap::emplace or other methods, is there memory leak in such cases?

greg7mdp commented 1 year ago

There was an issue indeed when the object construction failed with an exception (for example std::bad_alloc). That is issue #117. I just checked in a change to fix this. So if you get the current latest version from the repo, phmap should be fully exception safe. Thanks!

yiguolei commented 1 year ago

Thanks a lot