-
Notifications
You must be signed in to change notification settings - Fork 675
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
NavigationViewItemRevokers use WeakRef this pointers #6803
NavigationViewItemRevokers use WeakRef this pointers #6803
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@lhecker FYI |
Love it! 🙂 I'm a bit concerned about the supposed memory leak mentioned in the other PR. Some users tend to leave their computer running for up to multiple weeks after all, but I can't judge how to solve that, or how important solving it is. |
I am also quite concerned about introducing a leak. Terminal is not structured like other applications, as it uses transient NavViews that it expects to be destroyed when the user is done with them. |
@DHowett I might've misread the exchange between Stephen and Keith in #6797. A clarification about this new approach would be nice, since it lacks the "synchronous" cleanup that was happening before. I'm assuming there must've been a reason it was done that way... Testing for leaks in Windows Terminal will be a bit hard, since WinUI is leaking a lot of memory anyways already (~300kB every time we open the settings tab, which makes it hard to test for regressions). |
I believe that this should function correctly without any leaks. Stephen, can you verify in the debugger that the appropriate destructors are getting called as expected? With this change, my expectation is that NavView will not keep any NavViewItems alive that are not its children. When a NavViewItem is no longer referenced anywhere, it should get destroyed, and as part of the destruction its event handlers should get unregistered. |
We went with this fix instead: |
Rather than having navigation view track which items have revoker objects attached to them and ensure those get cleared during navigation view's destructor, we can simply have the callback object keep a weak ref to the navigation view rather than a raw pointer.