Reputation: 17832
Please specify the range of vector list ....
I want to store million of records in vector<>.
I have to copy Millions of records from one vector<> to another vector<> and then sort the vector and apply my filter function(unique id) to retrieve the record.
is this possible in vector
Regards, Karthik
Upvotes: 2
Views: 14837
Reputation: 89
I test it in my pc. Windows 7 32bit.
The result is 2^32/sizeof(CPoint3D)-1=268435455
, sizeof(CPoint3D)
is 16.
But max_size
is nothing. After it, m_point1.reserve(25641355)
, "Out of Memory" is showed.
25641355 < 268435455
Upvotes: -2
Reputation: 5693
What is the maximum size of an vector ....
I think you have answered your own question.
Theoretical limit for your system you can get with a function vector<T>::max_size()
. For instance:
vector<int> vec;
std::cout<<vec.max_size()<<std::endl;//prints max size for vector<int> in your system!
So just run this and check out the answer for your system.
However in practice the vector's allocated array must be in one consecutive memory block and even with less size memory allocation can fail. If you are going to use vector of ints with million elements I think you shouldn't have any problems. However for bigger objects it can be problematic.
Upvotes: 8
Reputation: 43575
There's no limit except the available memory. But: a vector requires all the memory to be in one consecutive memory area. If you want to store a million records, there might not be such a big memory area available.
In that case, it's better to use a deque
instead of a vector
.
Upvotes: 0