digitalmars.D.learn - what is going on here?
- forkit (13/13) Jan 04 2022 strange things happen when I compile (on windows) the code below
- H. S. Teoh (14/20) Jan 04 2022 I bet you it's the same problem I found a couple of years ago, where the
- H. S. Teoh (19/22) Jan 04 2022 Or the compiler would run out of memory before it gets to optimizing
- forkit (9/12) Jan 04 2022 yes, this sounds like it might be it.
- forkit (3/19) Jan 05 2022 Well, in my case, it was nice to see that the oom reaper thread
- H. S. Teoh (9/11) Jan 05 2022 I'm well-acquainted with the OOM reaper; it and dmd are good friends,
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; } // ----
Jan 04 2022
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
Jan 04 2022
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
Jan 04 2022
On Tuesday, 4 January 2022 at 23:37:57 UTC, H. S. Teoh wrote:... .. . Which seems to confirm my suspicions. Tyes, 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;
Jan 04 2022
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. TWell, in my case, it was nice to see that the oom reaper thread is working correctly ;-)
Jan 05 2022
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.
Jan 05 2022