Question: How to know how much memory is a BtreeMap using?
Is it possible to determine the size in bytes used by a BTreeMap with unbounded data types? I have a use case where I need to remove items from the map if the total size exceeds a certain threshold.
I don't think that's possible right now -- at least not in a clean way. I suppose it would make sense to add a size() function to the StableBTreeMap which would give you this information.
@ielashi Do you have an idea of how much work that would be?
Correct, this information isn't exposed right now. It's actually quite easy to expose, since we already track how many pages we're using in memory. We can add that to the list of improvements for us to take on next.