Lingering object references from event graph pins

Not sure if this is a bug as such, but it’s rather hidden and definitely has potential to cause issues.

I was trying to find out why one of my objects was not being destroyed when I expected it to be. Using the obj refs name= console commend I discovered that it was being referenced by a blueprint event graph. As far as I can tell, it seems that output pins on nodes in an event graph (but not a function graph) essentially act as class scope variables. When a node is executed, the output pins are assigned their values, and continue to hold this value indefinitely, or until being executed again and overwritten.

I can see to an extent why this is the case, since execution flow in an event graph can contain nodes such as Delay, meaning pin lifetime isn’t as simple as on a function call stack. Still, it seems like there should be a way to detect the end of an execution path and destroy all pin contents along that path. As things are, a large asset could remain in memory indefinitely even if all other references were nulled, just because it was returned from a node which was executed once.

I’ve just run into this too on 4.16.3, after discovering textures were not being unloaded (even though I’d removed their references) - blueprint nodes whose branch had long finished executing were holding the reference. This is pretty bad.

also have this issue on 4.18.3