Handling Linker Out of Memory Errors

From RAD Studio
Jump to: navigation, search

Go Up to Using ILINK32 and ILINK64 on the Command Line


When using the RAD Studio ILINK32 or ILINK64, you may receive the Fatal: Out of memory message. To handle it, you need to identify the Linker heap that is out of memory and increase its size.

To increase the memory size in the needed heap, do the following:

1. Go to Tools > Options > IDE > Compiling and Running.
2. To see which Linker heap caused the problem, select Diagnostic on the Verbosity menu.
3. Try to link again, and when you see the Fatal: Out of memory message, click the Output tab. It contains additional information that identifies which Linker heap was overrun.
4. On the Output tab, find the following line:

Overrun on linker heap:
The heap that you see after the Overrun on linker heap: message is the heap that was overrun.
Values for all heaps are listed below this line. Please see the example below.
  • Look at the two hex values following the heap that is overrun.
  • The first value shows the size required by the linker when it realized that the heap would be overrun.
  • The second value shows the allocated size.
  • Compare the first and second values and pick a value for the heap that exceeds the first value.

Handling errors.png
5. Now, you can increase the size of the needed heap. To do it, go to Project > Options > C++ Linker and in the Linker Heap Settings section, set the new heap size.

  • For the 32-bit Windows platform, there are 5 heaps. In most cases, it’s enough to increase 3 of them: Code Heap Size, Data Heap Size, or Info Heap Size. Please see the sample values used in a reported test case:
  • Code Heap Size: 0x14000000
  • Data Heap Size: 0x0d000000
  • Info Heap Size: 0x0B000000
  • RO Data Heap Size: 0
  • TDS Heap Size: 0
  • For the 64-bit Windows platform, there are 14 heaps. In most cases, it’s enough to increase 2 of them: Dwarf pubtypes Heap Size, or Dwarf aranges Heap Size. Please see the sample values used in a reported test case:
  • Code Heap Size: 0
  • Data Heap Size: 0
  • Dwarf abrbrev Heap Size: 0
  • Dwarf aranges Heap Size: 0
  • Dwarf info Heap Size: 0
  • Dwarf line Heap Size: 0
  • Dwarf loc Heap Size: 0
  • Dwarf macinfo Heap Size: 0
  • Dwarf pubtypes Heap Size: 0x02400000
  • Dwarf ranges Heap Size: 0
  • Dwarf str Heap Size: 0x08000000
  • Info Heap Size: 0
  • RO Data Heap Size: 0
  • TDS Heap Size: 0
C++Linker.png

6. Try to link again. In case you see the Fatal: Out of memory message again, repeat the procedure because you might need to increase the memory for other heaps too.

Note: Each application requires increasing different heaps and different values.

Command-Line Flags

In a command-line build, the linker will emit a table like the following example:

Turbo Incremental Link64 6.80 Copyright (c) 1997-2017 Embarcadero Technologies,
Inc.
Overrun on linker heap: info
Linker Heaps
------------
info                   0x12271000  0x12000000
code                   0x0487d000  0x08000000
rodata                 0x00159000  0x06000000
data                   0x029bb000  0x08000000
bss                    0x08000000  0x08000000
dwarf_aranges          0x00010000  0x00200000
dwarf_macinfo          0x00010000  0x00200000
dwarf_pubtypes         0x00275000  0x02000000
dwarf_info             0x04e57000  0x06000000
dwarf_abbrev           0x00040000  0x00200000
dwarf_line             0x0124d000  0x02000000
dwarf_str              0x036e0000  0x06000000
dwarf_loc              0x00070000  0x02000000
dwarf_ranges           0x00275000  0x02000000
Fatal: Out of memory

You can change the heap sizes the linker uses via the -GH flag for ilink32 or ilink64. Use -GH<heapname>=size to allocate a larger heap or multiple heaps. For example, to link the release version of the DLL OWLNext library, internal C++Builder developers use -GHinfo=0x13000000.

See Also