boost_multi阵列太大?bad_alloc错误

boost_multi array too large? bad_alloc error

本文关键字:bad alloc 错误 multi 阵列 boost      更新时间:2023-10-16

我正在编写一个程序来测试一个功能。但是,当我声明具有一定大小的 boost::multi_array 时,我会收到错误。我收到以下错误:

在抛出"std::bad_alloc"实例后终止调用 什么((: 标准::bad_alloc

我的代码如下所示:

#include <boost/multi_array.hpp>
#include <boost/array.hpp>
boost::multi_array<double,3> test ;
test.resize( boost::extents[1000][1000][1000] ) ;

如果我声明 2D multi_array或声明大小为 10x10x10 和 100x100x100 的 3D multi_array,我不会收到错误。

有人有任何想法来解决这个问题吗?这个问题编译器是否相关还是什么?

我使用Qt creator执行代码,并使用MinGW编译器。

在我的项目后期,我将使用维度为 12/13 的数组,每个维度的长度在 100 到 1000 之间,所以我真的需要它来工作。

提前感谢!

RAM 内存超出。

双精度占用 8 字节 -> 1000x1000x1000 双精度 = 8 GB 所需的 RAM。