I'm trying to find out how much memory (in Bytes) a list of lists is using.
The Problem is illustrated here:
It Shows a Container List storing pointers to other lists (the Storage Lists) each storing uniformly size elements (let's say 10 Bytes each). So the first Storage List is storing 4 Elements, next 30, then the next one 12 and 10 and the last one 5 Elements. All the Elements are of the same C++ Type (which is just a struct of plain old data).
My Aim: The Container List above should have current size variable, which keeps track of the number of bytes the lists he is pointing to (with all tracked space for *prev and *next pointers).
So far, what I tried, is using allocators to track the number of bytes allocated by the lists (through a static class variable). Although that leads to a problem with std::list::splice, when moving elements from list see here: The elements which are spliced to another Container List are not tracked. It should even be able to track the bytes transfered to add that bytes-Count to the current size of another Container List.
Do I have to avoid using the STD allocators for memory tracking and instead use boost's intrusive lists somehow for tracking memory like that?
What kind of C++ feature does possibly support me by solving my
problem?