Closed jamesob closed 5 years ago
Also, calcNumBytesTotal calculates the number of bytes I need to allocate at once. This includes the info byte and space for either the elements directly (unordered_flat_map), or just a pointer (unordered_node_map) and the actual data will be allocated in a separate bulk allocator
Ah, I see! My apologies. How would I express the bytes used by an unordered_node_map
(excluding the value data behind the node pointers)?
Maybe something like map.calcNumBytesTotal(m.mask() + 1)
?
No problem, I guess the name of the methods are a bit confusing. Yes, it should be map.calcNumBytesTotal(m.mask() + 1)
. Also be aware that whenever the map gets full, it doubles the size to 2 * (m.mask() + 1)
. After the map has rehashed all it's data into the newly allocated chunk, unordered_node_map
does not just free the old chunk but put into the bulk allocator so it can be repurposed for object allocations
While testing I found that memory reported by
calcNumBytesTotal()
seemed suspiciously low. This seems like an obvious bug but maybe I'm missing something.