So this doesn’t prevent, say, a character from getting destroyed- but anything which can’t be explicitly destroyed is kept in memory instead? Definitely explains some things I haven’t nailed down but have observed.
I think that is correct, yes.
Not sure the right solution is to clear the ref… Maybe instead of a hard reference these should be a weak ptr/ref. The event still retains the ptr and can reference the object, but if nothing else is referencing the object then it can be GC’d. Of course, if you don’t IsValid it, you can get a ‘Accessed Null’ error, but that problem happens anyway with Actors that get destroyed.
That’s what it should be doing, I think.
Well looks like it might be fixed in 4.17 already (as far as the LoadAsset node goes):
“Assets that are only referenced by pins inside active Blueprints will now correctly be garbage collected. This means that if you use LoadAsset to load something and do not store it for future usage, it will no longer stay in memory forever until the loading Blueprint is destroyed”.
(Will mark as answer when I get around to testing it there)
Blueprint nodes with object pins will hold a reference to that object indefinitely (or until that branch of nodes is executed again or the object is destroyed).
This could potentially be keeping some huge objects in memory that are no longer in use.
I noticed this when the textures loaded in my widgets were still in memory even after replacing the references manually and garbage collecting. No doubt most blueprinters aren’t aware of this and could be e.g. spawning objects that execute nodes references to other objects… this could be eating memory all over the place.
e.g. if you have something like this in the construct event of your widget:
That texture we loaded temporarily will be referenced basically forever, even though we only needed it for a brief moment, because we can’t unload widgets in blueprint and that node doesn’t get executed again.
This was [reported by someone else before][2] but it was an old version, posted in an obscure category, and potentially quite a harmful issue, so I’ve made an updated thread.
As the poster in the original thread says, it seems like BP should be able to clear those references when the branch has finished executing. So next time a GC happens they should be gone.
Can we get someone from epic to chime in on this please? This is a huge issue and I need to know if it has been addressed.
still have this issue on 4.18.3 (Create Widget)