Proper way to add a GC reference for a dynamically allocated UObject

I have an editor viewport client that I am working on that dynamically creates some proxies for tabs. It can reference them through its own overridden AddReferencedObjects() call, but that precludes them being dynamically allocated as needed.

What’s the proper way to reference them at runtime?

Hi,

I am using AddToRoot, but I do not know if this is the proper way.
Perhaps this helps:

http://www.reddit.com/r/unrealengine/comments/2cmi1k/memory_ownership_best_practices/

Greetings

This question was asked in ignorance of how AddReferencedObjects() works. I had assumed for some reason that it was called on startup/init of the owning object and thus couldn’t handle objects added after that.

It’s actually the opposite - it’s called every time the GC runs. Which makes it work just fine for dynamic objects. As long as in the AddReferencedObjects() method it makes sure to reference all of its objects, it works just fine.

AddToRoot doesn’t seem to be a good solution since it then means that the object is around forever (or at least until the game goes away.)