“[ilink32] Fatal: Out of memory” in C++ Builder

被刻印的时光 ゝ 提交于 2021-02-18 06:27:11

问题


After updating Embarcadero C++ Builder to a new version, our project suddenly fails to build. This happens just with one of our projects. For the most of the team members, identical code builds without errors. On my computer, linking fails every time.

In Build tab:

[ilink32] Fatal: Out of memory

In Output tab:

Build FAILED.
c:\program files (x86)\embarcadero\studio\18.0\Bin\CodeGear.Cpp.Targets(3517,5): error : Fatal: Out of memory

There is no more information.

If I enable Link with Dynamic RTL, the project links without errors. For example, if our Debug target has that setting enabled, the project links in Debug but not in Release.

How can I fix this problem? How do I give more memory for the linker?


回答1:


Explanation

On your computer, one of the linker heaps is too small for this project. The project links with Link with Dynamic RTL option, because in that case the linker needs less memory, and the heap just happens to be large enough.

You can use -GH linker option to increase that heap, but first you have to find out which heap overflows. To do that, enable diagnostic output in the linker.

Compiling with diagnostic output

Compiling from the command line:

call rsvars
MSBuild /v:diag YourProject.cbproj

Compiling from the IDE:

  • Go to Tools > Options > Environment Options
  • Change Verbosity to Diagnostic
  • After building the project, read output from the Output tab of the Messages window

Increasing heap sizes

Near the end of the output, you should find sizes of heaps, similar to this:

The "ILINK32" task is using "ilink32" from "c:\program files (x86)\embarcadero\studio\18.0\bin\ilink32.exe".
Turbo Incremental Link 6.75 Copyright (c) 1997-2016 Embarcadero Technologies, Inc.
Overrun on linker heap: tds
Linker Heaps
------------
system                 0x030d4000  0x08000000
tds                    0x08710000  0x09400000
c:\program files (x86)\embarcadero\studio\18.0\Bin\CodeGear.Cpp.Targets(3517,5): error : Fatal: Out of memory
The command exited with code 2.

In this case, overflow happened in heap tds, so we need to increase its size. The left column gives the number of bytes in use, and the right column gives the number of bytes allocated. The new size should be larger than the value that is currently in the right column.

In this case, tds size was 0x09400000, so we increase it to 0x0f400000 with the following option: -GHtds=0x0f400000.

In the IDE, go to Project > Options > C++ Linker. Add -GHtds=0x0f400000 to Advanced > Additional Options.

After saving project options, compile the project again. If the same heap overflows, you need to increase its size even more. If another heap overflows, you need to increase its size as well.

For example, if code heap overflows now, and you want to increase its size to 0x0a000000, you should change Additional Options to -GHtds=0x0f400000 -GHcode=0x0a000000.

If you increase the heap too much, you will get LME288 error instead. That means you have reached the maximum size for some heap. If even the maximum size is not enough for your project, it seems C++ Builder 10.2.3. has doubled the maximum size, so you could migrate to that version, or copy ilink32.exe from 10.2.3. installation to use with an older version of C++ Builder.

More details

  • How to report a C++ Compiler or Linker problem and workarounds
  • "Unable to perform link" error when compiling in RAD Studio XE8

Did this not fix the problem?

  • If you are using C++ Builder 10.0 or 10.1, try to patch your linker as described here: LME288 Error in C++ Builder
  • If you are using C++ Builder 10.2, patching the linker does not work, but you can try other solutions in the same link
  • C++ Builder 10.2. has settings for managing heaps: Handling Out of Memory Errors


来源:https://stackoverflow.com/questions/37537733/ilink32-fatal-out-of-memory-in-c-builder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!