Hi there!
I am very new to Unreal Engine, and I got confused about memory management and the Garbage Collector. I read the wiki and some online documentation, and checked the "Tower Defense"/"Strategy Game" code. Asuming that all references are kept in UPROPERTY()-warded pointers:
Does Unreal Engine Garbage Collector detect circular references by itself? That is: does it detect unconnected components of the object graph and deletes them?
Or do I have to use TWeakObjectPtr to break reference cycles?
An example of this:
In the "Tower Defense" sample, I checked that AStrategyGameController contains several UStrategyAIAction, and that the latter caches a weak reference to the former in UStrategyAIAction::SetController. Is this mandatory? Or is it an aid to the Garbage Collector performance?
(My use case is a strategy game where a "board" can contain "tiles", and the tiles keep a reference to the board to delegate some functionality clicked. Should this be a weak reference?)
Thanks!
I am very new to Unreal Engine, and I got confused about memory management and the Garbage Collector. I read the wiki and some online documentation, and checked the "Tower Defense"/"Strategy Game" code. Asuming that all references are kept in UPROPERTY()-warded pointers:
Does Unreal Engine Garbage Collector detect circular references by itself? That is: does it detect unconnected components of the object graph and deletes them?
Or do I have to use TWeakObjectPtr to break reference cycles?
An example of this:
In the "Tower Defense" sample, I checked that AStrategyGameController contains several UStrategyAIAction, and that the latter caches a weak reference to the former in UStrategyAIAction::SetController. Is this mandatory? Or is it an aid to the Garbage Collector performance?
(My use case is a strategy game where a "board" can contain "tiles", and the tiles keep a reference to the board to delegate some functionality clicked. Should this be a weak reference?)
Thanks!
Comment