Large 2D array gives segmentation fault

后端 未结 7 1654
一生所求
一生所求 2020-12-02 08:08

I am writing some C++ code in Linux where I have declared a few 2D arrays like so:

 double x[5000][500], y[5000][500], z[5000][500];

During

7条回答
  •  再見小時候
    2020-12-02 08:50

    You may want to try and use Boost.Multi_array

    typedef boost::multi_array Double2d;
    Double2d x(boost::extents[5000][500]);
    Double2d y(boost::extents[5000][500]);
    Double2d z(boost::extents[5000][500]);
    

    The actual large memory chunk will be allocated on the heap and automatically deallocated when necessary.

提交回复
热议问题