Open iddm opened 6 months ago
I doubt it will ever be exposed, but for a given version you can inspect the source. The immediate size is just std::mem::size_of::<HashMap<K, V>>()
, and the heap size comes from the computed layout here:
... where T = (K, V)
for a HashMap<K, V>
, and buckets
can be determined from the reported capacity like:
All of that is subject to change, and of course if your K
or V
types have additional indirect memory then you'll need to account for that too.
I missed RawTable::allocation_info
when I answered before, and you can get access to that through HashMap::raw_table
. However, the "raw" feature has been removed in #546 for the upcoming 0.15.
I need to calculate how much memory the hashmap object with all the contents occupies. How could I do that?