core.exception.InvalidMemoryOperationError@(0)

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jan 24 14:42:51 PST 2015


On 01/24/2015 04:16 AM, Bayan Rafeh wrote:
> This problem is a tough one. I've been getting this error when I run my
> unittests, and apparently it is caused by attempting an allocation in
> the destructor from what little I could find online about the subject.
>
> The error is triggered once all my tests are complete, so I'm assuming
> the garbage collector is running before termination, but I tried placing
> logging messages in all my destructors and I didn't get anything, so
> none of them are being called.
>
> Is there any other possible reason to get this error?

The allocations may be indirect. For example, formatting a string to log 
a message may allocate. Try marking your destructors as @nogc to see 
whether the compiler agrees.

I am not sure whether it would cause the same error but another reason 
for the error is touching reference members of a class, which may have 
been finalized before the object.

Ali



More information about the Digitalmars-d-learn mailing list