Unreal Engine Scope Guard
How to prevent the garbage collector to cleanup something within a scope?
FGCObjectScopeGuard
This can be especially usefull in lambda’s
UObject* CreatedObject = NewObject<UObject>();
AsyncTask(ENamedThreads::AnyThread, [CreatedObject]()
{
// Ensures CreatedObject won't be garbage collected in this scope
FGCObjectScopeGuard CreatedObjectGuard(CreatedObject);
};