Thread overview
D compiler is eating all the memory when compiling and then out of memory!
May 09, 2020
dangbinghoo
May 09, 2020
kinke
May 09, 2020
dangbinghoo
May 09, 2020
hi,

I have tried to build the hunt-sql package on Windows 7 32bit(with 3GB RAM), dmd and ldc2 both failed with default option "out of memory".

And after trying with `dub build-mode=singleFile`, dmd compiles all the .d file, but "out of memory" when linking. and ldc2 says 'single linking is not supported'.

we should at least compiles the program, we need to use memory the OS gived to US, not just "out of memory" and then quit.


and I tried to supply gc options to dmd and ldc2 it self, has no effects at all.

detailed err info:

----------------------------------------------------------------------------------------------------
dub build hunt-sql --build-mode=singleFile --compile=dmd


Compiling ..\AppData\Local\dub\packages\hunt-sql-1.0.7\hunt-sql\source\hunt\sql\visitor\functions\Ucase.d...
Compiling ..\AppData\Local\dub\packages\hunt-sql-1.0.7\hunt-sql\source\hunt\sql\visitor\functions\Unhex.d...
Compiling ..\AppData\Local\dub\packages\hunt-sql-1.0.7\hunt-sql\source\hunt\sql\visitor\functions\package.d...
Compiling ..\AppData\Local\dub\packages\hunt-sql-1.0.7\hunt-sql\source\hunt\sql\visitor\package.d...
Linking...
---
ERROR: This is a compiler bug.
Please report it via https://issues.dlang.org/enter_bug.cgi
with, preferably, a reduced, reproducible example and the information below.
DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction.
---
DMD v2.087.1

predefs   DigitalMars Windows CRuntime_Microsoft CppRuntime_Microsoft LittleEndian D_Version2 all D_InlineAsm D_InlineAsm_X86 X86 Win32 assert D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat
binary    C:\D\dmd2\windows\bin\dmd.exe
version   v2.087.1

config    C:\D\dmd2\windows\bin\sc.ini
DFLAGS    -IC:\D\dmd2\windows\bin\..\..\src\phobos -IC:\D\dmd2\windows\bin\..\..\src\druntime\import -lowmem '--DRT-gcopt=profile:1 maxPoolSize:1024' -L/OPT:NOICF
---

core.exception.OutOfMemoryError@src\core\exception.d(702): Memory allocation failed
----------------
0x005F7DBC
0x005956FC
C:\D\dmd2\windows\bin\dmd.exe failed with exit code 1.

----------------------------------------------------------------------------------------------------
dub build hunt-sql --build-mode=singleFile --compiler=ldc2

Compiling ..\AppData\Local\dub\packages\hunt-sql-1.0.7\hunt-sql\source\hunt\sql\visitor\package.d...
Linking...
Separate linking not implemented for LDC

# ldc2 --version
LDC - the LLVM D compiler (1.17.0):
  based on DMD v2.087.1 and LLVM 8.0.1
  built with LDC - the LLVM D compiler (1.17.0)


Thanks!

~~~~~
binghoo dang

May 09, 2020
On Saturday, 9 May 2020 at 03:54:29 UTC, dangbinghoo wrote:
> we should at least compiles the program, we need to use memory the OS gived to US, not just "out of memory" and then quit.

This is a well-known issue but also heavily depends on the compiled code (CTFE usage and recursive template instantiations etc.). -lowmem usually helps, but isn't supported with dub and DMD (but with LDC since v1.17).

> Separate linking not implemented for LDC

Has been fixed in the meantime (since dub bundled with LDC v1.18).
May 09, 2020
On Saturday, 9 May 2020 at 04:13:33 UTC, kinke wrote:
> On Saturday, 9 May 2020 at 03:54:29 UTC, dangbinghoo wrote:
>> we should at least compiles the program, we need to use memory the OS gived to US, not just "out of memory" and then quit.
>
> This is a well-known issue but also heavily depends on the compiled code (CTFE usage and recursive template instantiations etc.). -lowmem usually helps, but isn't supported with dub and DMD (but with LDC since v1.17).

just tested, -lowmem doesn't help even with LDC version 1.18.0, out of memory when linking again, but it seems it's working when compiling.

>
>> Separate linking not implemented for LDC
>
> Has been fixed in the meantime (since dub bundled with LDC v1.18).

yes, dub bundled with ldc in V1.18 just linked successfully using both dmd and ldc.


Thanks!