Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
692 views
in Technique[技术] by (71.8m points)

c++ - 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];`

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

LINK : fatal error LNK1248: image size (F85C8000) exceeds maximum allowable size (80000000)

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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...