c++ - Why: vector crash when I try to push_back more than 16777216 -
i trying push_back instances of object vector (e.g. a; vectora.push_back(a)) code crashes whenever try push_back more once size of vector more 16777216 (16*1024*1024) (the capacity of vector 16777216 well, means vector reallocate memory).
anyone knows how should deal issue? checked memory used 320mb.
since std::vector wrapper around basic c array, has same limitations normal array, described here: is there max array length limit in c++? agree comments above contiguous memory limit. work around can switch using std::vector other class, not use arrays ( map, list or deque depending on needs ). solution using several vectors.
Comments
Post a Comment