-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix memory leaks in activation. #689
Conversation
I'm not sure we can do that, it'd be a breaking change, no? Or do you just mean the internals for activation |
There would indeed be a breaking change in the The behavior of the activation stuff will not change. |
The interface has been adjusted. Paging @rikbosch to check if I did not fuck up Winforms activation. |
@jlaanstra it's looking OK. I've removed the unused observable declarations |
@rikbosch Thanks missed them apparently. @paulcbetts |
Cool! Thanks @jlaanstra @rikbosch! |
This PR fixes two memory leaks that cause views to stick around forever. This also fixes #684.
Memory Leak No. 1:
The
ActivationForViewFetcher
for Xaml wants to be notified of changes to theIsHitTestVisible
property and subscribes to it, but this subscription sticks around, even if the view is unloaded. BecauseIsHitTestVisible
is a dependency property, this leaks the view.This has been fixed by only listening to
IsHitTestVisible
when the view is loaded.Memory Leak No. 2:
The activation logic subscribes to the
ViewModel
property of a view to be notified of changes. Similar to leak no. 1, this subscription sticks around, even if a view is unloaded.This has been fixed by disposing this subscription when the view is unloaded.
Long-term Improvement
These fixes made the already complicated activation logic a little more complicated. I believe it has been discussed before why the activation logic consists of two observables, instead of one and I cannot remember what the reasons for having two were. Now might be a good time to refactor this into a single observable returning a bool indicating active or inactive.
Thoughts?