动态2维数组分配

use*_*961 0 c++

我正在创建一个动态二维数组并分配它.我的for循环在10-15次运行后出错(每次都不是相同的值),分配错误.任何帮助,将不胜感激.

__int32 aLarge = 8121432;
__int32 bLarge = 8121784;
ActualPosition** myPositions;

myPositions = new ActualPosition*[aLarge];

for (int x = 0; x < aLarge; x++)
{
    try
    {
        myPositions[x] = new ActualPosition[bLarge];
    }
    catch (bad_alloc& ba)
    {
        // Error here
    }
}
Run Code Online (Sandbox Code Playgroud)

Nat*_*ica 5

如果sizeof(ActualPosition) == 1那时你需要61,431 GB的内存来保存你的阵列.因此,除非你有一台非常大的计算机,否则你将耗尽内存.