自动分配超过2G [英] automatic allocation exceeds 2G

查看:396
本文介绍了自动分配超过2G的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名新程序员,将C ++编程作为业余爱好,并使用它来帮助解决工程计算问题.

I am a new programmer, taking C++ programming as a hobby and using it to help solve engineering calculation problems.

我正在尝试创建一个指向对象的三维数组.数组应具有索引[1000] [1000] [250].

I am trying to create a three-dimensional array of pointers to objects. The array should have the indexes [1000][1000][250].

在调试时,会出现以下错误消息:

When debugging the following error message appears:

严重错误C1126:自动分配超过2G

fatal error C1126: automatic allocation exceeds 2G

有人可以帮忙吗?

推荐答案

在32位处理器上,应用程序可以使用2 GB的内存,其中包含代码和所有内容在该图中.算一下:阵列本身总共大约有1 GB.您不太可能获得那么多连续的内存.即使你可以 您的指针所剩无几!而且在这种特殊情况下,您尝试将其分配在堆栈上,这更加受限制.

On a 32 bit processor you application can use 2 GB of memory, with code and everything included in that figure.  Do the math: Your array is about 1 GB all by itself. It is unlikely you can get that much contiguous memory.  And even if you could there would be little memory left for your pointers to point at!  And in this particular case you have attempted to allocate it on the stack, which is even more limited.

您将不得不缩小数组,并使用'new'分配它,而不是在堆栈上.如此大的实际问题需要将数据存储在文件中.甚至在数据库中.

You will have to make the array smaller, and allocate it with 'new' instead of on the stack.  Practical problems of this size require storing the data in files; perhaps even in a database.

 


这篇关于自动分配超过2G的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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