LINK:致命错误LNK1248:映像大小超过最大允许大小(80000000) [英] LINK : fatal error LNK1248: image size exceeds maximum allowable size (80000000)




I am doing some extremely large array processing. I do a global declaration of:

`float array[200][1600][811];`

当我在MS Visual Studio 2010中构建我的解决方案时,得到以下错误

When I build my solution in MS Visual Studio 2010, I get the following error


现在,我知道这相当于大约1 GB的程序内存。但是这个声明适用于 float [50] [1600] [811] 的声明,总共为250 MB。我知道默认的堆栈大小是非常有限的。
有一些我已经试过的东西。我通过属性 - >链接器 - >堆栈保留大小增加VS中的堆栈大小。这没有帮助。我改变了我的可执行文件运行在x64模式(据说可以寻址高达2GB内存!)。这也不帮助。

Now, I am aware this amounts to about 1 GB of program memory. But this declaration worked for a declaration of float [50][1600][811] which amounts to 250 MB. I know the default stack size is very limited. There are a couple of things I have already tried. I increased the stack size in VS through Properties -> Linker -> Stack reserved size. This didnt help. I changed my executable to run in x64 mode (which is said to address upto 2GB memory!). This didnt help either.

我不想在数组上做一个 malloc ,因为我知道需要他们在我的代码。我不得不使它们全局声明,以便我可以利用堆栈/堆内存。如果我在我的 Main()中声明它们,它会给我内存溢出的错误。

I do not wish to do a malloc on the array because I know for sure I need them in my code. I had to make them global declarations so that I can avail the stack/heap memory. If I declare them inside my Main (), it gives me error of memory overflow.


Any pointers would be greatly appreciated. Thanks.



It appears that even when you're building an x64 executable, the linker has limits more appropriate for an x86 build. Not much you can do about that.


The only solution is to allocate it from the heap. This should be usable in the same way as your original declaration.

typedef float partial_array[1600][811];
std::unique_ptr<partial_array> array = new partial_array[200];


登录 关闭
发送“验证码”获取 | 15天全站免登陆