the GC.
GC.inFinalizer
bool inFinalizer() nothrow @nogc @safeQueries the GC whether the current thread is running object finalization as part of a GC collection, or an explicit call to runFinalizers.
As some GC implementations (such as the current conservative one) don't support GC memory allocation during object finalization, this function can be used to guard against such programming errors.
Returns
true if the current thread is in a finalizer, a destructor invoked by