PSA (corrections below): #UnrealEngine users, please know the wonders of TInlineComponentArray and the TInlineAllocator template. Life changing stuff right here. Stop using TArray GetComponents and other small temporary containers on the heap. Please. Put an end to needless memory fragmentation. Be enlightened by the efficiency of stack memory. There's still time for you to see the light. Image text in following posts...
#GameDev #UnrealDev #UnrealTips #UE4Study #UE5Study #UE4 #UE5 #UE #CPP #Programming
Don't forget to boost to help a fellow dev!
Edit: Made a correction to first example - according to my IDE it resolves to a move constructor, not a copy constructor. It's still the worst of these options, but not as egregious as I initially thought.
Edit 2: Another correction - the inline allocator is not always stack-specific! If declared as a member of something allocated on the heap (such as being a member in a UObject) the inline allocation will be bundled into that heap memory!