[Question] UObject Pointer References - in containers

Hello Everyone,

Today is a core engine question, that may have already been asked, but I believe I am appending to.

In [Question] UObject Pointer References - Programming & Scripting - Unreal Engine Forums
an explanation is established but no real documentation is referenced. Also I am curious as to the TArray implementation and if what is said in the mentioned post is still true. So…
How do TArray arrays benefit from being marked as UPROPERTY? Also, does the same behavior apply to other containers, like TSet and TMap?

Best,
-Spiris

Yes to all. Benefits Planty. Docs avaivable. TSet & TMap currently can´t be replicated and maybe a couple minor things not fleshed out regarding the UPROPERTY() Macro but generaly speaking works the same as TArray.

You can find more Documentation regarding all sorts of Topics including Garbage Collection.

Have Fun =)

Good information, I was mostly curious about the tidbit on UObject* garbage collection and memory management, as in the original question it mentions that TArrays don’t free memory on their own, even as a UPROPERTY(), and may not really benefit from being marked as such when it comes to memory management. So unless I want to get the other UPROPERTY() benefits for my TArray of UObject*, there is no reason to mark them as such.
Part of me wants to think that in the past four years this could have changed, and wants to know if it has, so I can make the right decisions going forward.

So it looks like I misread a bit of it, and misunderstood a bit more. The truth of it is all mostly laid out in this doc:

It makes note that unreal engine containers TMap, TSet, TArray, etc all behave in the way mentioned in the original question. The object pointers in them of course can go null via destruction, so storing nullptrs and managing the memory that the object pointers take up in the containers is up to the user, but the objects themselves are handled by the engine as they no longer have references. At least that is how I am understanding it.

My old rule of thumb was if it has anything to do with UObjects, its best to keep it as a UPROPERTY, but going ahead I feel like I can make much better decisions on this now.

This seems like a good enough answer for me, if there is something I missed or needs more clarity, please clarify, either way, thanks!