How to do it...

The following code demonstrates the de-allocation of an instance of the UObject class:

UObject *o = NewObject< UObject >( ... ); 
o->ConditionalBeginDestroy(); 

This concept also works with any class derived from the UObject class. So, for instance, if we wanted to do this with the UAction object we created in the previous recipe, we would add the bold text in the following snippet:

// Create an object
UAction * action = NewObject<UAction>(GetTransientPackage(),
UAction::StaticClass()
/* RF_* flags */ );

// Destroy an object
action->ConditionalBeginDestroy();