www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Memory allocation failed in CT

reply Andrey <saasecondbox yandex.ru> writes:
Hello,
I have got a problem with compile-time calulations.
I have some code generator that should create some long string of 
code during CT and after generation I mixin it. If I run it 
normally - in run time - then there is no error and I get 
expected output - string with size ~ 3.5 MB.
If I run it in CT then I recieve an error:
 core.exception.OutOfMemoryError core\exception.d(702): Memory 
 allocation failed
 ----------------
 0x00007FF65A80BE73
 0x00007FF65A80BE73
 0x00007FF65A80BB46
 0x00007FF65A7FBA5C
 0x00007FF65A8035EC
 0x00007FF65A804311
 0x00007FF658BA733E
 0x00007FF658CC561F
 0x00007FF658CC0CD8
 0x00007FF658CB3728
 0x00007FF658CB3826
 0x00007FF658CB4762
 0x00007FF658CB3826
 0x00007FF658CB3CD0
 E:\Programs\LDC2\bin\ldc2.exe failed with exit code 1.
I don't understand why... The only operation in my generator is string concatination: _result ~= "some code...".
Jul 09 2019
parent reply Max Haughton <maxhaton gmail.com> writes:
On Tuesday, 9 July 2019 at 17:48:52 UTC, Andrey wrote:
 Hello,
 I have got a problem with compile-time calulations.
 I have some code generator that should create some long string 
 of code during CT and after generation I mixin it. If I run it 
 normally - in run time - then there is no error and I get 
 expected output - string with size ~ 3.5 MB.
 If I run it in CT then I recieve an error:
 [...]
I don't understand why... The only operation in my generator is string concatination: _result ~= "some code...".
Are you using the -lowmem flag? This enables the GC during compilation i.e. you might be running out of memory (CTFE is not efficient with memory during evaluation)
Jul 09 2019
next sibling parent Andrey <saasecondbox yandex.ru> writes:
On Tuesday, 9 July 2019 at 17:59:24 UTC, Max Haughton wrote:
 On Tuesday, 9 July 2019 at 17:48:52 UTC, Andrey wrote:
 Hello,
 I have got a problem with compile-time calulations.
 I have some code generator that should create some long string 
 of code during CT and after generation I mixin it. If I run it 
 normally - in run time - then there is no error and I get 
 expected output - string with size ~ 3.5 MB.
 If I run it in CT then I recieve an error:
 [...]
I don't understand why... The only operation in my generator is string concatination: _result ~= "some code...".
Are you using the -lowmem flag? This enables the GC during compilation i.e. you might be running out of memory (CTFE is not efficient with memory during evaluation)
I tried to turn on this flag but no success. The same error...
Jul 09 2019
prev sibling parent reply Andrey <saasecondbox yandex.ru> writes:
On Tuesday, 9 July 2019 at 17:59:24 UTC, Max Haughton wrote:
 On Tuesday, 9 July 2019 at 17:48:52 UTC, Andrey wrote:
I in addition wrote "buffer.reserve(10 * 1014 * 1024);" and it also doesn't help.
Jul 09 2019
parent reply Max Haughton <maxhaton gmail.com> writes:
Is this a 64 or 32 bit compiler? Also could you post the source 
code if possible?

You could try "--DRT-gcopt=profile:1" druntime flag to see if the 
compiler is running out of memory for real
Jul 09 2019
parent reply Andrey <saasecondbox yandex.ru> writes:
On Tuesday, 9 July 2019 at 19:04:53 UTC, Max Haughton wrote:
 Is this a 64 or 32 bit compiler? Also could you post the source 
 code if possible?

 You could try "--DRT-gcopt=profile:1" druntime flag to see if 
 the compiler is running out of memory for real
Thanks for help. I solved my issue by rewritting code.
Jul 12 2019
parent a11e99z <black80 bk.ru> writes:
On Saturday, 13 July 2019 at 06:25:37 UTC, Andrey wrote:
 On Tuesday, 9 July 2019 at 19:04:53 UTC, Max Haughton wrote:
 Is this a 64 or 32 bit compiler? Also could you post the 
 source code if possible?

 You could try "--DRT-gcopt=profile:1" druntime flag to see if 
 the compiler is running out of memory for real
Thanks for help. I solved my issue by rewritting code.
can u describe how u rewrote the code? so it can be solution for all of us: when u generate long string in CT for mixins and u get an exception u can do next ...
Jul 13 2019