Memory use and vectors
Posted on 2006-06-22
I'm about to use some really large vectors. Three of them may contain over 1 million doubles. Two of them are only used for a short period of time. I want to be memory wise, but I'm not sure how allocation is done with vectors.
The one vector that sticks around I declare in the normal manner and I assume is using the stack.
The other two I declare as pointers and new - delete the memory myself off the heap.
I'm guessing that as I push more elements into the vector it is handling heap allocation even if a standard stack declaration was used. In which case it doesn't really matter if I new - delete the vector to begin with.
So my question are, does it matter with vectors, or does it all come off the heap anyway? Are there performance or any other issues to consider? in general when using a structure that gets extremely large, is it better to keep your stack small and use the heap?