View source code
							
							
						
								Display the source code in core/memory.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								Improve this page
							
							
					
								Quickly fork, edit online, and submit a pull request for this page.
								Requires a signed-in GitHub account. This works well for small changes.
								If you'd like to make larger changes you may want to consider using
								local clone.
							
						Function core.memory.GC.inFinalizer
Queries the GC whether the current thread is running object finalization as part of a GC collection, or an explicit call to runFinalizers.
						
				static bool inFinalizer() nothrow @nogc @safe;
						
					
				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 the GC.
Example
// Only code called from a destructor is executed during finalization.
assert(!GCExample
enum Outcome
{
    notCalled,
    calledManually,
    calledFromDruntime
}
static class Resource
{
    static Outcome outcome;
    this()
    {
        outcome = OutcomeAuthors
Sean Kelly, Alex Rønne Petersen
License
					Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.