Will this cause a memory leak?

ref continues to reference the animation, and ref is referenced in the listener to ref.Stopped, so refdoesn’t get GC’ed and so the animation doesn’t get GC’ed either.

But it’s not really a leak. It’s just a single reference and a single Animation object that doesn’t get cleaned up. It doesn’t grow over time, so it never causes an issue.

If you really want ref and the animation to get cleaned up, you can try something like this:

When the connection gets disconnected, it doesn’t have to reference the closure you passed, so ref isn’t referenced anywhere and it can get cleaned up automatically when/if its scope is exited. According to his post it might not.