When using vector, \"Out of Memory\" show.
To fix it, I use max_size() to check, then reserve or push_back.
If the max_size() is bigger the reserved value, it should
vector::capacity() gives the maximum number of elements that can be stored in the vector without having a re-allocation, one which can potentially fail from std::bad_alloc
.
vector::max_size() has a different meaning, roughly similar to (INT_MAX / sizeof(element))
.
For more information on Windows memory management, see the MSDN article