2016-12-04 66 views
1

これは、VS 64ビットでコンパイルされたC++ 2015のstd :: bad_allocは、xが1120.push_backは()原因はstd :: bad_alloc

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); 
     } 
    } 
} 
} 
+0

あまりにも多くのメモリが使用されていると思います。クラッシュポイントに達したときに使用されているメモリの量を確認することができます。 –

+1

[いいえrepro](http://coliru.stacked-crooked.com/a/fafd1d273a5f4e1f) –

+0

@πάνταῥεῖそれは1040で終了します。私はcoliruでそれを試していたときに失効しました。 –

答えて

0

bad_allocここで、特にここで発生した、あなたが不足していることを意味しメモリの。 g_damagefunction vectorのdouble要素のサイズは、メモリの約2.68 GBに相当する(4400 x 2000 x 41 x sizeof(double))バイトです。ベクトル自体が占有するメモリの量を加算すると、コンピュータのRAMがプログラムの要件に不十分であるか、またはプログラムが多すぎるメモリを使用していることがはっきりとわかります。私は後者の場合と思われる。

関連する問題