max_size() - the absolute maximum number of elements that the vector can store. Using the default dispenser, it is usually std::numeric_limits<std::size_t>::max() / sizeof(T) . That is, this is the largest array of this type that you could create.
However, you could never actually allocate this array. The modules loaded by your program use some of the address spaces of your program, as well as the stacks of each thread. You will likely have other dynamically allocated objects in your program (allocated by you or the runtime). All this contributes to fragmentation of the address space, which means that the largest contiguous block of available address space is much smaller than the total amount of available address space.
In short, in practice it is impossible to select a vector with max_size() elements.
source share