向量存储限制的向量 - 获取“Microsoft C++ 异常:std::bad_alloc 在内存位置 0x0031650C".错误 [英] Vector of vector storage limitations - getting "Microsoft C++ exception: std::bad_alloc at memory location 0x0031650C." error

查看:87
本文介绍了向量存储限制的向量 - 获取“Microsoft C++ 异常:std::bad_alloc 在内存位置 0x0031650C".错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 C++ 中,我正在读取几个大型网格数据集进行处理.最近,其中一个数据集在我开始处理之前就破坏了我的代码.

In C++ I am reading in several large gridded datasets for processing. Recently, one of these data sets broke my code before I even got to the processing.

数据集有 5765 列和 5872 行,总共 33852080 个单元格.好吧,在单个向量容量限制下双倍,对吗?或不?我目前正在努力解决这个问题.

The data set had 5765 cols and 5872 rows for a total of 33852080 cells. Well under the individual vector capacity limit for a double, right? Or not? I'm trying to figure that out currently.

尝试将内部第 2496 个向量推回原始向量时抛出异常.

The exception is thrown trying to push_back the inner 2496th vector into the original vectors.

代码如下:

slopeGrid.reserve(rows);  
flowDirGrid.reserve(rows);     
flowAccumGrid.reserve(rows);  
tempGrid.reserve(rows);
inflowGrid.reserve(rows);
TWIgrid.reserve(rows);


for(int k=0; k<rows; k++)
{
    elevation.push_back(*new vector<double>(cols));
    ATB.push_back(*new vector<double>(cols));
    Area.push_back(*new vector<double>(cols));

    slopeGrid.push_back(*new vector<double>(cols));   
    flowDirGrid.push_back(*new vector<double>(cols));     
    flowAccumGrid.push_back(*new vector<double>(cols));   
    tempGrid.push_back(*new vector<double>(cols));
    inflowGrid.push_back(*new vector<double>(cols));
    TWIgrid.push_back(*new vector<double>(cols));

}

推荐答案

所以你有 3400 万个对象,对吧?如果这些对象足够大,我认为每个 Windows 32 位进程达到 2 gig 的最大值不会那么难......

So you have 34 millions objects, right? If enough of those objects are big enough I think reaching the maximum of 2 gigs per Windows 32 bit process wouldn't be that hard...

这篇关于向量存储限制的向量 - 获取“Microsoft C++ 异常:std::bad_alloc 在内存位置 0x0031650C".错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆