java 0x7fffffff,错误:数组的总大小不能超过0x7fffffff个字节

I have a small C++ program that requires a large 2d array.

int distanceArray[282][9900000];

I am aware that a standard 32 bit console application would be unable to allocate this much memory to my process due to the 2GB cap on 32 bit applications. However, despite the fact that I have configured my compiler to use the native amd64 toolset, I still get the same error when I try to build my application:

Error C2148 total size of array must not exceed 0x7fffffff bytes

I have 16GB of RAM on my system, so I know that my physical memory should not be an issue. If my calculations are correct, this should only take up around 3GB. However, I don't understand why I can't seem to get the 64 bit compiler to work correctly. I have followed the directions on Microsoft's website that outline how to use the 64 bit compiler, but no matter what I do, i receive the same error. Any help would be greatly appreciated. Thank you!

I am aware that this question has been asked before, but the existing answers have not been helpful to me. Thank you for any attempt at helping me find my problem.

解决方案

As suggested by MSalters, an std::vector<:vector>> was definitely the way to go.

For anyone who is still having this problem, here is how I initialized it:

std::vector<:vector>> distanceArray(282, std::vector(9000000, -1));

9,000,000 columns are created within every row of 282 items, and each value is initialized to -1 at the start.

Thanks to everyone who commented for the help!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值