Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
January 04, 2022 what is going on here? | ||||
---|---|---|---|---|
| ||||
strange things happen when I compile (on windows) the code below with: dmd -m64 (compilation just crashes - no error message at all) or ldc2 -m64 (compilation works, but memory usage during compilation goes completely wild! upto 22GB, then down to 7GB, then finally completes.) // ---- module test; void main(){ static char[2147483646] arr; } // ---- |
January 04, 2022 Re: what is going on here? | ||||
---|---|---|---|---|
| ||||
Posted in reply to forkit | On Tue, Jan 04, 2022 at 10:53:50PM +0000, forkit via Digitalmars-d-learn wrote: [...] > // ---- > > module test; > void main(){ static char[2147483646] arr; } > > // ---- I bet you it's the same problem I found a couple of years ago, where the compiler translates the above code to something that individually initializes every element of the array. I.e., there would be 2.1 billion assignments, one for each element in the array. Of course, afterwards the optimizer would merge them into something saner, but while the compiler is unfolding all those assignments, its memory usage would obviously skyrocket. Try setting `arr = void;` to see if it makes a difference. If it does, it's probably the same problem. T -- Skill without imagination is craftsmanship and gives us many useful objects such as wickerwork picnic baskets. Imagination without skill gives us modern art. -- Tom Stoppard |
January 04, 2022 Re: what is going on here? | ||||
---|---|---|---|---|
| ||||
On Tue, Jan 04, 2022 at 03:34:41PM -0800, H. S. Teoh wrote: [...] > Of course, afterwards the optimizer would merge them into something saner, but while the compiler is unfolding all those assignments, its memory usage would obviously skyrocket. Or the compiler would run out of memory before it gets to optimizing away those assignments, so it would just outright crash. I ran your code on my computer and got this: uncaught exception core.exception.AssertError@src/dmd/common/outbuffer.d(204): OutBuffer: out of memory. ---------------- ??:? _d_assert_msg [0x5616e935648e] ??:? _ZN9OutBuffer7reserveEm [0x5616e9350bda] ??:? nothrow @trusted void dmd.common.outbuffer.OutBuffer.position(ulong, ulong) [0x5616e935129c] ??:? _Z11ElfObj_termPKc [0x5616e933bcd6] Aborted Which seems to confirm my suspicions. T -- They say that "guns don't kill people, people kill people." Well I think the gun helps. If you just stood there and yelled BANG, I don't think you'd kill too many people. -- Eddie Izzard, Dressed to Kill |
January 05, 2022 Re: what is going on here? | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On Tuesday, 4 January 2022 at 23:37:57 UTC, H. S. Teoh wrote:
>
> ... .. .
>
> Which seems to confirm my suspicions.
>
>
> T
yes, this sounds like it might be it.
I tried using = void;
.. results:
dmd -m64 -> just results in an 'out of memory' message (but at least i get a message this time)
ldc2 -m64 -> again, compiles ok, but this time memory usage during compilation never exceeds about 2.1GB (compared to 22GB when not using =void;
|
January 05, 2022 Re: what is going on here? | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On Tuesday, 4 January 2022 at 23:37:57 UTC, H. S. Teoh wrote:
>
> Or the compiler would run out of memory before it gets to optimizing away those assignments, so it would just outright crash. I ran your code on my computer and got this:
>
> uncaught exception
> core.exception.AssertError@src/dmd/common/outbuffer.d(204): OutBuffer: out of memory.
> ----------------
> ??:? _d_assert_msg [0x5616e935648e]
> ??:? _ZN9OutBuffer7reserveEm [0x5616e9350bda]
> ??:? nothrow @trusted void dmd.common.outbuffer.OutBuffer.position(ulong, ulong) [0x5616e935129c]
> ??:? _Z11ElfObj_termPKc [0x5616e933bcd6]
> Aborted
>
> Which seems to confirm my suspicions.
>
>
> T
Well, in my case, it was nice to see that the oom reaper thread is working correctly ;-)
|
January 05, 2022 Re: what is going on here? | ||||
---|---|---|---|---|
| ||||
Posted in reply to forkit | On Wed, Jan 05, 2022 at 08:00:45AM +0000, forkit via Digitalmars-d-learn wrote: [...] > Well, in my case, it was nice to see that the oom reaper thread is working correctly ;-) I'm well-acquainted with the OOM reaper; it and dmd are good friends, and love to throw parties esp. when CTFE and Recursive Templates are in town. :-P T -- What doesn't kill me makes me stranger. |
Copyright © 1999-2021 by the D Language Foundation