Inexplicable invalid memory operation when program terminates
pineapple via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Sep 5 10:48:11 PDT 2016
On Monday, 5 September 2016 at 17:33:17 UTC, pineapple wrote:
> Am I missing something or is this an obnoxious bug with the GC?
Oh, I've been trying to figure this out on and off for days and
of course five minutes after I post I fix the problem. I'm not
really sure why, but it did fix it.
In the example the window class destructor was being called. I
found that if I did `delete win;` at the end there it worked
fine, but otherwise the GC was tripping up? I removed a console
output statement and rewrote a thing using a foreach loop instead
of a filter range and it stopped complaining.
I'm realizing now, too, that the reason I was getting the same
error in commits long before I added that particular thing the GC
disliked was an entirely different one.
That was not fun to debug.
On Monday, 5 September 2016 at 17:42:18 UTC, Lodovico Giaretta
wrote:
> InvalidMemoryOperationError is raised when you try to allocate
> memory inside a destructor called by the GC. I see from your
> repository that the destructor of Window uses a function called
> log defined by yourself. That function uses writeln internally.
> writeln is not @nogc, so it may be that that call to log in the
> destructor is actually allocating memory.
That was in fact part of the problem
More information about the Digitalmars-d-learn
mailing list