加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

[zz]LINK : fatal error LNK1248: image size exceeds maximum allowable size (80000000)

(2012-08-30 11:37:47)
标签:

visual

fortran

array

size

杂谈

分类: HighPerformanceComputation
From http://stackoverflow.com/questions/11211840/link-fatal-error-lnk1248-image-size-exceeds-maximum-allowable-size-80000000
Comments: For my case, the array defined is just too big. Imagine how big a 15^6 array is!!! http://engine.adzerk.net/v/v.gif?i=eyJVc2VyIjpudWxsLCJDYXRlZ29yaWVzIjpbXSwiQ3JlYXRlZE9uIjoiXC9EYXRlKDEzNDYyOTc1ODgzMTApXC8iLCJJZCI6IjE3YmU4NGNjLTRiMmMtNDRmYy1hYmExLWNlNDJlYjFhN2I3YSIsIlJlbW90ZUlQIjpudWxsLCJVc2VyQWdlbnQiOm51bGwsIlJlZmVycmVyVXJsIjpudWxsLCJVcmwiOm51bGwsIkNyZWF0aXZlSWQiOjU5MjAsIlJTU0tleSI6bnVsbCwiQWRUeXBlSWQiOjQsIlNpdGVJZCI6ODI3NywiQ2hhbm5lbElkIjoxMTc4LCJQcmlvcml0eUlkIjoxNTY4LCJOZXR3b3JrSWQiOjIyLCJab25lSWQiOjQzLCJMb2NhdGlvbiI6bnVsbCwiQ2FtcGFpZ25JZCI6ODQ3LCJQYXNzSWQiOjI0NDQsIkJyYW5kSWQiOjQxNCwiRmlyc3RDaGFubmVsSWQiOjExNzgsIkltcHJlc3Npb25Db3VudCI6MSwiVXNlcktleSI6bnVsbCwiS2V5d29yZHMiOiJjKyssdmlzdWFsLXN0dWRpby0yMDEwLG1lbW9yeS1tYW5hZ2VtZW50LG91dG9mbWVtb3J5ZXhjZXB0aW9uIiwiRGVsaXZlcnlNb2RlIjoxLCJSZXZlbnVlIjowLCJJc1RyYWNraW5nQ29va2llRXZlbnRzIjpmYWxzZSwiUGhhbnRvbVBhc3NJZCI6MCwiUGhhbnRvbUNyZWF0aXZlUGFzc0lkIjowLCJDcmVhdGl2ZVBhc3NJZCI6ODgwNiwiSXNWYWxpZFVBIjpmYWxzZSwiSXNOb1RyYWNrIjpmYWxzZSwiTWF0Y2hpbmdLZXl3b3JkcyI6bnVsbH01fatal error LNK1248: image size exceeds maximum allowable size (80000000)" TITLE="[zz]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.

http://www.gravatar.com/avatar/88753efb648678b6c14d64fe715b216b?s=32&d=identicon&r=PGfatal error LNK1248: image size exceeds maximum allowable size (80000000)" />
Jim
2,65441229
asked Jun 26 at 16:29
http://www.gravatar.com/avatar/e2fbc11ad94ffa8c4fe159d04c4e7b8a?s=32&d=identicon&r=PGfatal error LNK1248: image size exceeds maximum allowable size (80000000)" />
Benny
653

75% accept rate


You shouldn't (and you can't) put that on the stack. Don't even try. For all practical purposes, heap allocation is unavoidable for something of that size. – Mysticial Jun 26 at 16:32

It is right time to find out what heap memory allocation is all about. Or, here is x64 platform to feel comfortable for some time. – Roman R. Jun 26 at 16:33

The first thing to ask is whether you need to use an array in the first place. You don't if most of the values remain set to the default or if you can process them in such an order that they don't all need to be in memory at the same time. – reinierpost Jun 26 at 16:38
2  
That declaration isn't going on the stack or the heap, it's going into global process memory. That's the only reason the linker is seeing it. – Mark Ransom Jun 26 at 16:51
feedback

2 Answers

up vote 1 down vote accepted

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];
answered Jun 26 at 17:05
http://www.gravatar.com/avatar/2a1f9f4986b58015691eb2014e78869f?s=32&d=identicon&r=PGfatal error LNK1248: image size exceeds maximum allowable size (80000000)" />
Mark Ransom
81.1k365170


Does unique_ptr know to use delete[] to clean up? – Mark B Jun 26 at 18:14

@MarkB, not 100% sure. Microsoft's unique_ptr documentation mentions a partial specialization for arrays that would cover it, but I don't know if it's part of the standard and I don't know if my typedef defeats it. – Mark Ransom Jun 26 at 18:21

It appears to exist outside of MS, too... but even if it didn't, you could always create your own deleter. In either case, the OP is presumably talking about a object (in the general sense) created at runtime that persists for the lifetime of the application. The host OS can always be relied upon to clean up any memory allocation when the process exits, right? Lazy, but it would suffice, surely. – Rook Jun 26 at 18:59

@Rook If it was just leaked sure, but mixing new and delete forms is, as I recall, undefined rather than just harmless. – Mark B Jun 26 at 19:21

True. I was thinking of skipping the whole delete phase entirely. A custom non-deleting deleter would do, but it seems like a rather roundabout way to do things! – Rook Jun 26 at 20:02
show 3 more comments
feedback
http://engine.adzerk.net/v/v.gif?i=eyJVc2VyIjpudWxsLCJDYXRlZ29yaWVzIjpbXSwiQ3JlYXRlZE9uIjoiXC9EYXRlKDEzNDYyOTc1ODgzMTApXC8iLCJJZCI6IjQwYTQ2OTRiLTczMjEtNDY0MC05MmM1LWQ3NTk4YTVlNTlkNiIsIlJlbW90ZUlQIjpudWxsLCJVc2VyQWdlbnQiOm51bGwsIlJlZmVycmVyVXJsIjpudWxsLCJVcmwiOm51bGwsIkNyZWF0aXZlSWQiOjEwNzY4LCJSU1NLZXkiOm51bGwsIkFkVHlwZUlkIjo0LCJTaXRlSWQiOjgyNzcsIkNoYW5uZWxJZCI6MTE3OCwiUHJpb3JpdHlJZCI6MTU2OCwiTmV0d29ya0lkIjoyMiwiWm9uZUlkIjo0NCwiTG9jYXRpb24iOm51bGwsIkNhbXBhaWduSWQiOjg0NywiUGFzc0lkIjoyNDQ0LCJCcmFuZElkIjo0MTQsIkZpcnN0Q2hhbm5lbElkIjoxMTc4LCJJbXByZXNzaW9uQ291bnQiOjEsIlVzZXJLZXkiOm51bGwsIktleXdvcmRzIjoiYysrLHZpc3VhbC1zdHVkaW8tMjAxMCxtZW1vcnktbWFuYWdlbWVudCxvdXRvZm1lbW9yeWV4Y2VwdGlvbiIsIkRlbGl2ZXJ5TW9kZSI6MSwiUmV2ZW51ZSI6MCwiSXNUcmFja2luZ0Nvb2tpZUV2ZW50cyI6ZmFsc2UsIlBoYW50b21QYXNzSWQiOjAsIlBoYW50b21DcmVhdGl2ZVBhc3NJZCI6MCwiQ3JlYXRpdmVQYXNzSWQiOjE2ODg1LCJJc1ZhbGlkVUEiOmZhbHNlLCJJc05vVHJhY2siOmZhbHNlLCJNYXRjaGluZ0tleXdvcmRzIjpudWxsfQ2fatal error LNK1248: image size exceeds maximum allowable size (80000000)" TITLE="[zz]LINK fatal error LNK1248: image size exceeds maximum allowable size (80000000)" />

If you are malloc adverse, you have two immediately obvious possibilties. C++11 has a nice array type which might help:

std::array<std::array<std::array<float, 50>, 1600>, 811> matrix;

Or you could consider using std::vector with a loop to initialise all the values correctly:

std::vector<std::vector<std::vector<float>>> matrix;
matrix
.reserve(50);

for (size_t i = 0; i < 50; i++)
{
    std
::vector<std::vector<float>> submatrix;
    submatrix
.reserve(1600);

   
for (size_t j = 0; j < 1600; j++)
   
{
        std
::vector<float> row;
        row
.resize(811);

        submatrix
.push_back(row);
   
}

    matrix
.push_back(submatrix);
}

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有