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

fix: cache pages to avoid system memory leak #400

Closed
wants to merge 6 commits into from

Conversation

huynhsontung
Copy link
Owner

@huynhsontung huynhsontung commented Jul 2, 2024

Update: Memory leak is due to pages not unregistering the handler for view model's PropertyChanged events when navigating away. The ViewModel keeps a hard reference to the Page, so somehow both cannot be GC.

Looks like Pages don't get efficiently cleaned up when they are navigated away from. New Page instances are created on every navigation and never get properly released. It's confirmed to be a system-level memory leak. 🤦 Set NavigationCacheMode to Enabled can fix that.

https://learn.microsoft.com/en-us/answers/questions/111194/memory-leak-on-uwp-with-target-versions-10-0-17763
microsoft/microsoft-ui-xaml#934
microsoft/microsoft-ui-xaml#3597

@huynhsontung huynhsontung changed the title feat: cache pages for better memory efficiency fix: cache pages for better memory efficiency Jul 2, 2024
@huynhsontung huynhsontung changed the title fix: cache pages for better memory efficiency fix: cache pages to avoid system memory leak Jul 2, 2024
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.

1 participant