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

查看:13727
本文介绍了LINK:致命错误LNK1248:映像大小超过最大允许大小(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

LINK:致命错误LNK1248:图片大小(F85C8000)超过最大允许大小(80000000)

现在,我知道这相当于大约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.

推荐答案

看起来即使你在构建一个x64可执行文件,对于x86构建。你不能这么做。

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];

这篇关于LINK:致命错误LNK1248:映像大小超过最大允许大小(80000000)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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