Skip to content
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

Address memory leaks #782

Merged
merged 2 commits into from
Apr 2, 2021
Merged

Address memory leaks #782

merged 2 commits into from
Apr 2, 2021

Conversation

manodasanW
Copy link
Member

@manodasanW manodasanW commented Apr 1, 2021

The changes in this PR addresses the memory leaks observed in the samples from #781. It is a variant of the changes attempted initially in #673 , but addresses some of the concerns about finalizers on the RCW handling release by moving that to the IObjectReference itself which owns the lifetime. In addition, it makes sure in aggregated scenarios, any QIs don't increment the COM ref count maintained by the CLR and that for non aggregated scenarios XAML is informed of those references.

From testing, these changes seem to demonstrate an improvement and no leaks are observed in the samples in #781

Fixes #413

@AaronRobinsonMSFT
Copy link
Member

First pass looks really good. I will check it out again tomorrow. Two things I would like to see.

  1. A test run against some of the WinUI lifetime tests.
  2. The performance impact of some of these changes. This is now doing a lot more QI work - which the original .NET Native didn't need to do. We may be able to be clever/smart once we confirm it is correct.

Next step is to get the final .NET fix in as well. We should try and validate that leak scenario still exists. I believe the easiest way is to use the WeakReference<T> across the native/managed boundary.

@BenJKuhn
Copy link
Member

BenJKuhn commented Apr 1, 2021

(YAY!)

@manodasanW
Copy link
Member Author

The 26 WinUI lifetime tests now all pass.

@manodasanW manodasanW requested a review from MikeHillberg April 1, 2021 20:00
@AaronRobinsonMSFT
Copy link
Member

I believe the easiest way is to use the WeakReference across the native/managed boundary.

@manodasanW Any luck trying to use that?

@manodasanW
Copy link
Member Author

@AaronRobinsonMSFT that is on my list to try out and will get back to you once I do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WinUI 3 Page objects are being leaked on navigate in a C#/WinRT app
4 participants