we are developing a kind of CAD application using UE4 and I’m constantly facing this annoying problem: let’s say I have my main controller (eg. entry point of my custom application) where I bind inputs to handlers, instantiate uobjects, spawn default actors… many of these uobjects are systems / subcontrollers / services that will get called everywhere in my codebase (objects factories, network services, etc.).
I was thinking about creating some kind of resolver much like in a dependency injection scenario where you configure your container by registering types. The actual implementation would ideally require a
TMap[FString, UObject*] where all the instances are stored. But this approach leaks memory as uobjects in tmaps get garbage collected.
How would you manage instances of these kind of objects in such application? Right now I have an
UPROPERTY for each system / service in my main controller, along with getters, and each spawned actor has a reference to the main controller… I feel like this implementation doesn’t scale well should we start adding more and more systems to it.
Have a nice day,