Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[controls] fix memory leak in
Application.OpenWindow()
Context: dotnet#10029 I could reproduce a memory leak by doing: App.Current.OpenWindow(new Window { Page = new ContentPage() }); I found that `App.Current._requestedWindows` just held onto every `Window` object forever. This is a perfect example of where using `ConditionalWeakTable` solves the issue: https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.conditionalweaktable-2 The only other change I made was to use `Guid.ToString("n")` as it removes `{`, `}`, and `-` characters from the string. Note this doesn't fully solve dotnet#10029, as I still see something else holding onto `Window` in my example. This is WIP, as I'm interested in what my `WindowsDoNotLeak` test will do on all platforms.
- Loading branch information