Closed benstadin closed 7 months ago
No, it doesn't. What is your exact use case? If you want to use as little memory as possible, I recommend using sparsepp.
I have multiple maps which independently grow and shrink in size during the lifetime of the application. This application runs multiple days and thus the overall memory required by all maps is very high.
You really should try sparsepp, it should work well for this. It has not been updated in a while though, so missing newer C++ APIs, but still more modern and up-to-date than Google's sparsehash map, which it is derived from.
Does it actively free memory when resizing?
To guarantee that a map's memory use is cleared, you can swap it with a temporary map, for example:
MyMap map;
map.emplace(....);
...
MyMap().swap(map); // swap map with an empty temporary, which is immediately destroyed
Does it actively free memory when resizing?
@benstadin yes it does.
As far as I understand Google's sparse hash map maintains a low memory footprint by deallocation memory after a certain threshold. Does parallel-hashmap provide a similar feature in order to release memory when the map size is reduced?