Blueprint node pins hold object references indefinitely

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.