B
Ben
I have a program which is using a lot of memory.
At the moment I store a lot of pointers to objects in std::vector.
(millions of them)
I have three questions:
1) Lets say the average Vector is of size 2. How much memory can I
save by storing my pointers in c++ arrays, rather than vectors.
2) I looked into using boost::array to save memory, but you need to
know the size at compile time, as opposed to run time. I want to
number of elements in the array to be configurable at run time, but I
don't need to be able to resize my vectors. This seems to rule our
boost::array, since it is templatized on size. Are there any other
ideas for array classed I can use to save memory over std::vector?
3) If I just use a standard C++ array, how do I create an array of
pointers on the fly. An array of Objects is easy:
array = new Object[size];
How do I do the same for an array of pointers to Objects?
Thanks,
ben
At the moment I store a lot of pointers to objects in std::vector.
(millions of them)
I have three questions:
1) Lets say the average Vector is of size 2. How much memory can I
save by storing my pointers in c++ arrays, rather than vectors.
2) I looked into using boost::array to save memory, but you need to
know the size at compile time, as opposed to run time. I want to
number of elements in the array to be configurable at run time, but I
don't need to be able to resize my vectors. This seems to rule our
boost::array, since it is templatized on size. Are there any other
ideas for array classed I can use to save memory over std::vector?
3) If I just use a standard C++ array, how do I create an array of
pointers on the fly. An array of Objects is easy:
array = new Object[size];
How do I do the same for an array of pointers to Objects?
Thanks,
ben