Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
July 09, 2019 Memory allocation failed in CT | ||||
---|---|---|---|---|
| ||||
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...".
|
July 09, 2019 Re: Memory allocation failed in CT | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrey | 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)
|
July 09, 2019 Re: Memory allocation failed in CT | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Haughton | 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...
|
July 09, 2019 Re: Memory allocation failed in CT | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Haughton | 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.
|
July 09, 2019 Re: Memory allocation failed in CT | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrey | 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 |
July 13, 2019 Re: Memory allocation failed in CT | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Haughton | 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.
|
July 13, 2019 Re: Memory allocation failed in CT | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrey | 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 ...
|
Copyright © 1999-2021 by the D Language Foundation