Should I unsubscribe from delegates On Destroy?

I’ve used C# a lot, and in C# if you subscribe to an event you need to unsubscribe from it when the actor is destroyed or whatever, because the subscriber leaks in memory. I’ve subscribed to some dynamic delegates in Unreal, and I am curious if I have to unsubscribe On Destroy? In the documentation and everywhere I checked you just subscribe once and then do nothing? Is this ok, or there might be memory leaks?

Not sure about this but when you register a callback from a delegate you use “addDynamic” and pass a reference to the function to be executed, the name tells me that this is a dynamic callback so if the actor gets destroyed then the reference becomes null, I’m guessing that by then the garbage collector from Unreal should take care of the rest.

I made some research and I believe you are right. Thank you :slight_smile:

As “nullbot” said. The garbage collector takes care of everything. You don’t need to unsubscribe.