I'm still talking about the per-allocation overhead. Suppose:
Code:
typedef CMemoryManager<int> int_ptr;
typedef std::vector<int_ptr> ptr_vec;
// Measure memory usage here.
int *demo = new int;
// Measure memory usage here.
delete demo;
ptr_vec manyPointers(100000);
// Measure memory usage here.
for(ptr_vec::iterator it = manyPointers.begin(); it != manyPointers.end(); ++it) {
*it = new int;
}
// Measure memory usage here.
The initial two measurements ought to tell you how much overhead new itself has. This is a guideline to measure the total overhead from your constructs. Every int is 4 bytes large, plus new's own overhead. Make that, for demonstration purposes, 12 bytes in total. Then the 100000 ints we allocate take 1200000 bytes of memory.
The difference between the last two measurements minus the 1200000 bytes of the ints themselves tell you how much overhead you introduce.