TARRAY of UObject garbaged

Hi,

I have a TARRAY of UObject that I create at in my constructor.

The UObject are garbaged even if there are added in the TARRAY variable. I read in multiple place that shouldn’t be the case but it is. Did I miss somthing?

For the moment, the way to keep them was the add them to the Root, but for me it seems to be the wrong approach.

Any help is welcome.

Thanks!

Add UPROPERTY () before varable decleration even without specifiers, it will prevent from garbage collector interprate varable as garbage.

Yes I added it already.

It seems that the issue is more when I add my object.

If I’m doint it in the constructor, they are garbaged, if I’m doing it in PostInitComponent, they are kept.

I will raise a bug for this.

Thanks

I can verify I have the same problem
(Using 4.5.1 release)

Same problem in 4.8.1

UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Inventory, meta = (AllowPrivateAccess = "true"))
TArray<UGameItem*> InventoryBelt;

Items, added in constructor garbaged.
My workaround - create initial items in “construction script” blueprint