Everything I’ve seen about soft references has told me they work like this:
Using a soft reference means the referenced class will not be forced to load into memory
referenced class only takes up memory when it’s already there, or when the user specifies
However, let’s suppose I create a class called BigClass. It has a bunch of bloat in it and takes a good chunk of memory. Then I make another class, an Actor subclass called SoftTest. Inside SoftTest is nothing but a single variable, a soft reference to BigClass.
Why is BigClass loaded into memory when only SoftTest is placed in the scene? Like fresh editor, empty scene, use “Obj List class=BigClass_C”, no instances. Add SoftTest to the scene, suddenly there are instances in memory. I thought the point of soft references was to not take (much) memory space unless told otherwise.
If this is not the case, then please, help me understand what I’m missing
Okay sure, but that’s for soft class references… so then what are soft object references for? Is it to keep classes inside your referencee class from being loaded by the referencer? like for example if BigClass had soft references to other classes, they wouldn’t be loaded by SoftTest if it hard referenced BigClass?
Or i guess summarized:
if we had classes A, B, and C, and → means a reference link
I am familiar with and have used interfaces quite a bit. I was just hoping soft refs would help me avoid using so many interface funcs. In BP I find that I often run into situations where a BP function and an interface function are similarly named. At least enough so that I either have to select the specific function with arrow keys / mouse, or type out the entire function name. The more I use interfaces to decouple, the more often it happens. I suppose it’s probably just a naming skill issue, but it would be nice if there was a way to filter in and out certain interfaces from the context menu.
So I instead tried a sort of “brain” or “public accessor” component type of setup. Just have a lighter weight component that holds any data / funcs / delegates I know is going to be used as public a lot. Then I can use an interface to retrieve this component and cast to the lighter weight class. Still most likely uses up a bit more memory than just interfaces this way, but for me its less annoying lol
this is a good pattern, and often we do need a hard ref anyway, ie for event dispatchers. if its a component though you can ditch the interface and use GetComponentByClass