question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discussion: Memory leak in NavigationView even though I cleared the child page element while unloading.

See original GitHub issue

Discussion: Why memory leak occurs while displaying a custom code snippets view in a NavigationView’s child page.

Describe the bug

While using the NavigationView control to navigate child pages, the child page’s elements were cleared in its own unloading methods. But, the child pages retaining their memory after closing them.

Steps to reproduce the bug

  1. Open and build the sample App8.zip with x86 or x64 architecture.
  2. To take a memory leak report, click the Debug menu item and select the Performance Profiler in Visual studio.
  3. Select the Memory Usage check box and click Start button
  4. Visual studio will start the diagnostic session and launching the application
  5. Click the TakeScreenshot button in the Visual Studio diagnostic session.
  6. Click on the DemoList Navigation Menu Item in the application.
  7. Click on the Code Snippets1 grid view item and its opens a code snippets page
  8. Click on the Back app bar button
  9. Repeat steps 7 and 8 for CodeSnippets 2andCodeSnippets 3
  10. Click the Empty Page Navigation Menu Item.
  11. Wait for 2 min and click the Force GC in the Visual Studio diagnostic session.
  12. Click the TakeScreenshot button in the Visual Studio diagnostic session.
  13. Then, click the Stop Collection

ezgif com-gif-maker (9)

Memory leak report:

image

image

Expected behavior

Memory should be the same or low as the initial screenshot.

Version Info

NuGet package version: [WinUI 3 - Windows App SDK 0.8: 0.8.1]

Windows app type

WinRT

Windows version

October 2020 Update (19042)

Related Links

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:13

github_iconTop GitHub Comments

8reactions
l619534951commented, Mar 19, 2023

Is this issue not a high priority? “WinUI 3 Gallery” and “PowerToys” also has this problem(WinAppSDK: 1.2).

1reaction
l619534951commented, Apr 25, 2023

@vfib memory usage still increase when more than 500 MB, but the growth will slow down. if you continue navigation, your app will crash. (tested with WinAppSDK 1.3)

Powertoys can be used for testing, navigated to difference page many times, Powertoys will crash.

Temporary solutions is:

private void ContentFrame_Navigated(object sender, NavigationEventArgs e)
{
    System.GC.Collect();
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

SwiftUI - memory leak in NavigationView
Tested with Xcode 11.4 / iOS 13.4 - ViewModel destroyed as expected. Here is complete test module code: struct CloseBarItem: View { //...
Read more >
Debug DOM memory leaks with the Detached Elements tool
A memory leak can occur in your application when an element is no longer attached to the Document Object Model (DOM) tree, but...
Read more >
2022 Chevrolet Bolt EUV Owner's Manual
Shown when the service manual has additional instructions or information. 0 : Shown when there is more information on another page — “see...
Read more >
2022 Chevrolet Corvette Owner's Manual
This manual describes features that may or may not be on the vehicle because of optional equipment that was not purchased on the...
Read more >
Memory leaks?
Guys, have you come accross memory leaks when using Ranorex? I noticed that whenever I use ranorex lib, the memory allocated by my...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found