Maximum size of vectors

Hi,

I have a vector of vectors declared as:

vector<vector<int>> v;

My program works fine with a small number of insertions to v. However, with a huge number of insertions my program stops working without telling me the reason... I guess that vectors might not grow after a certain size (im not sure)

1. What is the maximum size that a vector of vectors can grow?
2. I'm using Microsoft visual studio 2012, Is their anything I can do with the settings to increase the size of my vector? something beyond 1000000 rows?

Best regards,
Nouf
See http://www.cplusplus.com/reference/vector/vector/max_size/
A vector can fail to allocate memory at any time before the theoretical maximum capacity though. It depends on the system. Also, vectors reaching large sizes can take exceedingly large times to operate on if you use erase or something that doesn't have constant complexity.

Edit:
What Glandy said.
Last edited on
Thank you... It was helpful... I have tried the code... the program executed until it reached 2G and then it gave me a run time error since I reached the maximum size... However, with my program when I have a huge number of insertions to the vector, the program just stops execution without giving me a run time error which means that the vector did not reach the limit yet... but what do you think the reason would be???

what would be the reason of a program stopping its execution without any runtime error after too many insertions and calculations on the vector? Note that the program works fine with few insertions to the vector...
When you say stops execution, what exactly do you mean? Does your program main just return 0? Does the program crash?
Vector::insert has linear time complexity depending on how many elements there are after the position you're inserting at, and if the vector has to reallocate that's also got linear complexity up to the entire size of the vector. So it's likely your program isn't crashing it's just taking a really long time to execute.
Thanks for the replies...

I meant by stops execution, the program does not display any results instead it gives me the phrase "press any key to continue".

I only insert values to the vector... I don't erase anything...

I found my problem.. I had a reallocation exception, I found it while debugging the program... It happens when the vector gets very big and tries to be reallocated somewhere else in the memory...
Last edited on
Topic archived. No new replies allowed.