Prevent garbage collecting, how to RemoveFromRoot?

Do not ever use AddToRoot() or SetFlags(RF_MarkAsRootSet) if you do not have a custom cleanup function that will remove this flag BEFORE exiting game (before MarkIsPendlingKill() by engine loop). Passing an UWorld pointer as Outer in NewObject() and a flag RF_Standalone - is enough to keep your UObject alive during gameplay and auto destruction on game end.