Variable and memory usage

I got a question,If set some variable in c++,like this:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = baseMoves)
class UPaperFlipbook* walkFlipBook;
and set a real flipbook in blueprint.

question is,will this walkFlipBook be loaded to memory at the beginning when it was created.
and if it has 100 different movementFlipbook,all these 100 assets will be loaded at the beginning?that’ll be a heavy cost.

appreciate for any answers~

Yeah they’ll get loaded if they aren’t already in memory (you’re not duplicating them, every instance will point to the same set of flipbooks). You can use TSoftObjectPtr<UPaperFlipbook> if you want better control of when the assets get loaded. You may want to use async streaming. See docs below. Make sure to keep “hard” references to objects you want to keep in memory, e.g. have a standard UPROPERTY(Transient) UPaperFlipbook* pointer to the asset you’re currently using.

Obviously you should first consider whether this is actually a problem. Constantly loading assets all the time could easily be a bigger performance problem than just keeping them in memory. Modern devices have several GB of available memory, so don’t worry too much about holding on to a few MB.

https://docs.unrealengine.com/4.26/en-US/ProgrammingAndScripting/ProgrammingWithCPP/Assets/ReferencingAssets/

1 Like

Thank you~~

Ya…For some reason,my character has a lot of flipbooks…As you said,so I can’t use blueprint to assign them,that’s easier for me and animator.
OK~I will use `TSoftObjectPtr,Thank you again~~:)