Memory Management of local UObject * pointer

In my experience normal UObject pointers are registered with the UE4’s garbage collection on calling NewObject(), the pointer in a local scope will disappear when the function completes, but the referred to object is still managed, as far as calling ConditionalBeginDestroy, you can let the garbage collector handle it once it finds that it has no references, or you can call it yourself when you need to, checking IsPendingKill() if needed, etc.

If I want a UObject* to persist over a period of time outside of a local scope, I will make a UPROPERTY() on another valid UObject in the scene, which attaches it to a chain of references that are managed by the world they are in, cleaned up whent he scene changes, Actor/owning UObject is destroyed, etc.

There are also ways you can make UObjects persist through a period of time by adding them to the root set, then removing them when needed, though it is almost never necessary and should only be practiced if you know exactly how you want to manage when that object is garbage collected.

Hope this helps,
Spiris