Creating inventory slots using UObject

Hello,

I’m creating an inventory that is slot-based, that can support different slots types
and the slots are UObjects that hold information like UItem*, Quantity etc…

I was wondering if the slots can get garbage collected ?
Is it a good idea to create it that way if i plan to Save/Load or Replicate it later?

How im doing it

BaseActorComponent Holds a TArray / TMap of slots : TArray and/or TMap

Then on BeginPlay i initialize TMap / TArray to empty elemts eg. 30 Elements of type USlot*

UBaseActorComponent : UActorComponent
|__  UInventoryComponent
|__  USomeLootBoxComponent


USlot : UObject
|__ UInventorySlot
|__ USomeOtherSlotType

UObject are not tied to the world instance, so they won’t clear with level, but they all properly cleaned once they not referenced by anything

So if you reference them (have them in object pointer) only in components as you do now, they should be properly collected. You can laso use world instance as objetc outer, tis should help out