R
Rune Allnor
Hi all.
I have a data structure which I naively implemented as
std::vector<std::vector<T> >. Right now I'm testing it
with 8000 vectors of vectors, each of which contain on the
order of 1000 elements, ending up somewhere on the
order of 350 MB of memory. I am nowhere near exhausting
any meory limits.
The program was compiled with default 'release' settings
(VS2008) and takes forever to run.
So I am curious about the memory footpint here. I am
aware that the elements of a std::vector occupy a continuous
block of memory. Is this memory assigned dynamically
or is *everything* in the std::vector assigned as one
dynamic block?
That is, are the internal control variables etc located in a
memory block 'close' to the data values of the vector,
or can the data values be located somewhere else
(e.g. on the heap)?
That is, if everything is one continuous block of memory,
all the data might have to be copied to new areas of
memory as the vectors grow. Which might explain
why the thing takes so long to run.
Rune
I have a data structure which I naively implemented as
std::vector<std::vector<T> >. Right now I'm testing it
with 8000 vectors of vectors, each of which contain on the
order of 1000 elements, ending up somewhere on the
order of 350 MB of memory. I am nowhere near exhausting
any meory limits.
The program was compiled with default 'release' settings
(VS2008) and takes forever to run.
So I am curious about the memory footpint here. I am
aware that the elements of a std::vector occupy a continuous
block of memory. Is this memory assigned dynamically
or is *everything* in the std::vector assigned as one
dynamic block?
That is, are the internal control variables etc located in a
memory block 'close' to the data values of the vector,
or can the data values be located somewhere else
(e.g. on the heap)?
That is, if everything is one continuous block of memory,
all the data might have to be copied to new areas of
memory as the vectors grow. Which might explain
why the thing takes so long to run.
Rune