I need to gather statistics about memory usage in my program.
My code is mostly written using STL.
Is there any way of learning how much memory is being consumed by an STL object?
For example,
string s1 = "hello";
string s2 = "hellohellohellohellohellohellohellohellohellohellohellohellohello";
How much memory is consumed by s1 and s2?
Obviously, sizeof(string)+s1.length() is not quite accurate.