On Thursday, 1 January 2015 at 15:14:41 UTC, Timo Gransch wrote:
Hi,

I have a class which unzips an archive into a temporary directory below the system temp folder. I want to delete this temporary directory in the class's destructor, but when I call rmdir there, I get an

core.exception.InvalidMemoryOperationError@(0)

Destructors are usually called by GC, during a GC cycle, so allocating and deallocating memory is not allowed there. If some function allocates, reallocates or deallocates, it will cause this very error. This means you shouldn't use any functions in a destructor that are not @nogc.

Solution in this case: call rmdir not from destructor.

Reply via email to