Large 2D array gives segmentation fault

后端 未结 7 1559
一生所求
一生所求 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<double, 2> 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.

    0 讨论(0)
提交回复
热议问题