Can obj=NewObject(outer) be garbage collected before "outer"?

Hello everyone!

Suppose I created instance MyObj with the code below inside my actor class and MyObj is not stored in UPROPERTY():

auto MyObj = NewObject<DerivedFromUObject>(this)

Does it establish Child-Parent relationship between MyObj and this, thus preventing MyObj from being garbage collected before the actor instance is GC’ed?

Does it works like in Qt library?

// Qt example: myObj lifetime is now tied to parent.
auto myObj = new QObject(parent);
delete parent; // deletes myObj as well

No, it does not prevent it, MyObj can be garbage collected before the outer (your actor) is.

Simply speaking, the child is going to held a reference to the actor through Outer, but the actor does not automatically hold a reference to the objects it’s an outer of.

Thanks for the clarification!