.push_back()在大向量上导致std::bad_alloc 这是在64位与C++ 2015之间编译的。std::bad_alloc发生在x特别是1120的地方 static std::vector<std::vector<std::vector<double>>> g_damagefunction; static std::vector<std::vector<double>> g_has_damagefunction; static std::vector<double> null_v_double; static std::vector<bool> null_v_bool; static std::vector<std::vector<double>> null_vv_double; int main(){ for (int x = 0; x < 4400; x++) { std::cout << x << '\n'; g_damagefunction.push_back(null_vv_double); g_has_damagefunction.push_back(null_v_bool); for (int y = 0; y < 2000; y++) { g_damagefunction[x].push_back(null_v_double); g_has_damagefunction[x].push_back(false); for (int i = 0; i < 41; i++) { g_damagefunction[x][y].push_back(0.0); } } } } 静态std::向量g_损伤函数; 静态std::向量g_具有_损伤函数; 静态std::向量null_v_double; 静态std::向量null\u v\u bool; 静态std::向量空值vv双精度; int main(){ 对于(int x=0;x

.push_back()在大向量上导致std::bad_alloc 这是在64位与C++ 2015之间编译的。std::bad_alloc发生在x特别是1120的地方 static std::vector<std::vector<std::vector<double>>> g_damagefunction; static std::vector<std::vector<double>> g_has_damagefunction; static std::vector<double> null_v_double; static std::vector<bool> null_v_bool; static std::vector<std::vector<double>> null_vv_double; int main(){ for (int x = 0; x < 4400; x++) { std::cout << x << '\n'; g_damagefunction.push_back(null_vv_double); g_has_damagefunction.push_back(null_v_bool); for (int y = 0; y < 2000; y++) { g_damagefunction[x].push_back(null_v_double); g_has_damagefunction[x].push_back(false); for (int i = 0; i < 41; i++) { g_damagefunction[x][y].push_back(0.0); } } } } 静态std::向量g_损伤函数; 静态std::向量g_具有_损伤函数; 静态std::向量null_v_double; 静态std::向量null\u v\u bool; 静态std::向量空值vv双精度; int main(){ 对于(int x=0;x,c++,heap-memory,bad-alloc,C++,Heap Memory,Bad Alloc,这里的bad_alloc表示内存不足。g_damage函数向量中双元素的大小将为(4400 x 2000 x 41 x sizeof(double))字节,相当于您内存的2.68 GB。如果您将向量本身占用的内存量添加到其中,您可以清楚地看到,您的计算机的RAM不足以满足程序的要求,或者您的程序使用了太多内存。我怀疑是后者。我认为它使用了太多内存。您当达到崩溃点时,应该能够看到使用了多少内存。@πάνταῥεῖ 它在1040结束。我在coliru上试用时过期了。我对代码做了一点修改(我把一个替身

这里的bad_alloc表示内存不足。g_damage函数向量中双元素的大小将为(4400 x 2000 x 41 x sizeof(double))字节,相当于您内存的2.68 GB。如果您将向量本身占用的内存量添加到其中,您可以清楚地看到,您的计算机的RAM不足以满足程序的要求,或者您的程序使用了太多内存。我怀疑是后者。

我认为它使用了太多内存。您当达到崩溃点时,应该能够看到使用了多少内存。@πάνταῥεῖ 它在1040结束。我在coliru上试用时过期了。我对代码做了一点修改(我把一个替身当作一个傻瓜)。我看了看“无需重做”,似乎只有1000-something@BryanChen我在科里鲁的第一轮比赛中也被淘汰了,但没有重赛。