STL Vector overhead
Posted on 1998-04-20
Can anybody tell me what the overhead of using a STL vector template is. For example if I create a vector using a char*
and then I set the list to be 10 items long and initialise each pointer to point to a 256 character string how much memory would actually be used up?
for (int x=0;x<10;x++)
char* empty = new char ;
something like this maybe: (256*10)+(sizeof(char*)*10) + overhead?
What I am eventually trying to achieve is a list which has x spaces all allocated at the start of the program that I can then copy strings into when "things" happen in my program. Like a debug list that can tell me if anything was out of sequence. When I reach the end of the list I will start back at the beginning, but I need to decide how much memory I am prepared to give over to the list before it will overwrite itself.
Would it be better just to use an array: