Dear all,
In a prototype i’m building I use an array of type:
TArray<UFZ_Cell*, TInlineAllocator<100000>> Cells;
The TInlineAllocator keyword allows me to create these cells on the stack (in an attempt to improve performance). The problem is that my array is being garbage collected because i can’t make stack allocated TArray’s UPROPERTY(). This also goes for TFixedAllocator. How can i manage this?
Thanks a million! :rolleyes:
Move information on stack allocated TArray’s:
https://www.unrealengine.com/en-US/b…or-performance
Did you try something like, maybe:
TStaticArray< TSharedPtr<UFZ_Cell>, TInlineAllocator<100000> > Cells;
?
Euhm that doesn’t seem to compile:
error C2993: ‘TInlineAllocator<100000,FDefaultAllocator>’: illegal type for non-type template parameter ‘NumElements’
Would that allow me to make it UPROPERTY()? Or would that prevent garbage collection from throwing away my data?
Even though it’s a few years later:
TArray<TStrongObjectPtr<UFZ_Cell>, TInlineAllocator<100000>> Cells;
You could also use TSharedPtr, but the TStrongObjectPtr is best for UObjects while TSharedPtr is more for default types like int, float etc.