I’ve noticed that the Size Maps of my actors are still indicating big amount of memory being used in the Editor even though I’m mostly using Soft References, Async loading/Loading and casting from the loaded assets.
For example, when I create a variable (Soft object) in an actor and don’t do anything with it, I still see the Size Map referencing a lot of things from the Actor used in the variable. I thought that this would only be loaded into memory when I call a Loading Asset node.
I understand that I can make a really light parent class for BP and use them for the Soft Refenrece in order to load less but at some point, I’m always supposed to load the assets to retrieve their variables.
Am I missing something or misunderstanding the concept?
I 'm using UE5.
I’m still learning on the topic so I might have misunderstood something! I’m curious.
Hey @Derelicts_Romain,
They are made to keep references to objects or assets that may not exist and reference assets without loading them. Soft object variables also won’t create hard references to the blueprint. While normally object references would throw errors if you would delete assets and don’t fix references, you might be damaging the Blueprint files. In technical terms, they hold the path to the object or asset, in a similar way as INI config or data tables.
The blueprint will auto-cast to object reference if you want to call a function on an asset or send it when a used asset will be automatically loaded. If an object doesn’t exist the cast would return null, but you can check validity beforehand too.
Aside from referencing assets that may not exist at runtime, one of many possible reasons is to reference an asset without loading it when it’s not really needed. You can reference objects on the level, without them needing to be loaded. You can make soft references and set actors on the level as default.
In short, they have a pretty specific use. Say you want an inventory system, but only want specific qualities from these objects loaded without actually loading the full object, or even the full system, this is when you’d want to soft reference.
I found an article from a previous thread if you’d like some more insight, too:
Thank you for taking the time to reply.
Sorry, I might not have been clear in my message but I do understand what Soft References are and their purpose.
What I don’t understand is why my assets are still loaded in memory in my Editor (according to Size Maps from actors) even though I’m using Soft References.
For example, let’s say I make a Test Actor (empty) and only add a variable that references another Actor called “Normal Item” (much more complex actor) and makes this variable soft.
I’m wondering if this is a bug in 5. I see examples online of people using soft object/class refs in BP and the change is reflected in the size map and the reference viewer. But not so in 5.
Interesting! Thank you for checking this out ClockworkOcean.
I’ve asked another developer working with UE and he told me that he thought maybe the Size Map is not really reliable in Editor as the editor is already loading everything into memory.
I’ve seen people on utube change to a soft ref and the size map updates. ( pretty sure ). Also you get pink lines in the reference viewer. ( also doesn’t work ).
Yeah, for me, the Size Map definitely updates when I use for example a Data Table with Soft Ref vs Hard Ref (but for things like Static Meshes, Textures, not actors).
But in the case of the variable with the actor, nothing changes, which is really weird…
Indeed, it’s the same for the Reference Viewer. My pins are red for the variables from the Data Table (the soft ref of static meshes) but for the variable of the actor, it’s still indicated as hard.
So I tried the same test in Unreal Engine 4 and get the same behavior. Everything is loaded as soon as I create a Soft ref variable from another actor, according to the Size Map.
I’m guessing this is the normal way UE is loading it!
Apologies for the light necro, but I am finding myself looking into this too. I’ve found this post and this other post that all point to the same conclusion; adding a class soft reference variable seems to load the class into memory.
I’m writing this partially to express surprise as it seems counter to the whole purpose of soft references, but also a realisation that so long your soft reference type is of a lighter base class, this is perhaps not so much of an issue. For instance, you could make the variable of type ‘actor soft-ref’, which casts a very wide net but also doesn’t load anything new.
E.g. I had a blueprint class ‘Banana’ I filled with some static meshes and skeletal meshes. In a new BP I had a ‘Banana’ class soft ref, and using the console command memreport -full I confirmed it was indeed loaded into memory (even after restarting)
Then, I changed the variable type to an Actor soft ref, but set its value to ‘banana’, and restarted the editor. I opened the BP with the variable in it, to ensure that BP was loaded, then the same console command created a memory report with no mention of the ‘banana’ class in it.
I have noticed that once a soft reference gets loaded in the editor it will be loaded until the engine closes. That can be the reason why the soft reference is shown in the size map.