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

Memory leak with Shell Navigation #22313

Open
AshokKumarVis96 opened this issue May 9, 2024 · 5 comments
Open

Memory leak with Shell Navigation #22313

AshokKumarVis96 opened this issue May 9, 2024 · 5 comments
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout memory-leak 💦 Memory usage grows / objects live forever platform/android 🤖 platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.)
Milestone

Comments

@AshokKumarVis96
Copy link

AshokKumarVis96 commented May 9, 2024

Description

With Maui Shell Navigation, we could see some page are not disposed properly when we are not using them as Routed page.

In provided sample, we have 3 Shell Pages, in which Main Page & First Page is not registered as routed page. Second Page is added as routed Page. After Navigating through these page, only MainPage & FirstPage is not releasing its object, like Second Page.

Note: We are using memory toolkit to monitor the memory leaks. Reference : https://github.com/AdamEssenmacher/MemoryToolkit.Maui?tab=readme-ov-file

Steps to Reproduce

  1. Run the below provided sample in Android/ iOS.
  2. Main Page will be opened, Click on 'Move to First Page'
  3. Once First Page is opened, Click on 'Move to Second Page'
  4. Once Second Page is opened, Click on Back button in Navigation toolbar
  5. Now Check the output window, We can see the list of objects which are not disposed.(Refer below screenshot)

We can see, objects of Second Page will be released properly, not with First and Main page.

image

Link to public reproduction project repository

Replication Sample

Version with bug

8.0.21 SR4.1

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

8.0.0-rc.1.9171

Affected platforms

iOS, Android

Affected platform versions

Android 13, iOS 15.0

Did you find any workaround?

Registering Route for Affected pages in AppShell.Xaml.cs, resolves the issue.

image

Relevant log output

[shellmemoryleak] Explicit concurrent mark compact GC freed 17074(1945KB) AllocSpace objects, 4(144KB) LOS objects, 58% free, 4387KB/10MB, paused 90us,1.498ms total 12.673ms
[shellmemoryleak] Explicit concurrent mark compact GC freed 1231(104KB) AllocSpace objects, 0(0B) LOS objects, 58% free, 4347KB/10MB, paused 51us,1.437ms total 9.896ms
[shellmemoryleak] Explicit concurrent mark compact GC freed 15(64KB) AllocSpace objects, 0(0B) LOS objects, 58% free, 4347KB/10MB, paused 101us,2.365ms total 16.422ms
[shellmemoryleak] Explicit concurrent mark compact GC freed 7(64KB) AllocSpace objects, 0(0B) LOS objects, 58% free, 4347KB/10MB, paused 57us,1.408ms total 11.902ms
[shellmemoryleak] Explicit concurrent mark compact GC freed 7(64KB) AllocSpace objects, 0(0B) LOS objects, 58% free, 4347KB/10MB, paused 71us,1.450ms total 10.240ms
[shellmemoryleak] Explicit concurrent mark compact GC freed 7(64KB) AllocSpace objects, 0(0B) LOS objects, 58% free, 4347KB/10MB, paused 81us,2.266ms total 15.936ms
[shellmemoryleak] Explicit concurrent mark compact GC freed 7(64KB) AllocSpace objects, 0(0B) LOS objects, 58% free, 4347KB/10MB, paused 151us,2.123ms total 15.141ms
[shellmemoryleak] Explicit concurrent mark compact GC freed 7(64KB) AllocSpace objects, 0(0B) LOS objects, 58% free, 4347KB/10MB, paused 90us,1.973ms total 14.553ms
[shellmemoryleak] Explicit concurrent mark compact GC freed 7(64KB) AllocSpace objects, 0(0B) LOS objects, 58% free, 4347KB/10MB, paused 90us,2.229ms total 16.963ms
[shellmemoryleak] Explicit concurrent mark compact GC freed 7(64KB) AllocSpace objects, 0(0B) LOS objects, 58% free, 4347KB/10MB, paused 98us,2.352ms total 16.999ms
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Warning: ❗🧟❗Label is a zombie
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Warning: ❗🧟❗LabelHandler is a zombie
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Warning: ❗🧟❗Label is a zombie
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Warning: ❗🧟❗LabelHandler is a zombie
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Warning: ❗🧟❗Button is a zombie
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Warning: ❗🧟❗ButtonHandler is a zombie
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Warning: ❗🧟❗VerticalStackLayout is a zombie
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Warning: ❗🧟❗LayoutHandler is a zombie
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Warning: ❗🧟❗MainPage is a zombie
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Warning: ❗🧟❗PageHandler is a zombie
[ViewRootImpl@51f174d[MainActivity]] ViewPostIme pointer 0
[ViewRootImpl@51f174d[MainActivity]] ViewPostIme pointer 1
[WindowOnBackDispatcher] sendCancelIfRunning: isInProgress=falsecallback=androidx.activity.OnBackPressedDispatcher$Api34Impl$createOnBackAnimationCallback$1@6d5a864
[ViewRootImpl@51f174d[MainActivity]] ViewPostIme pointer 0
[ViewRootImpl@51f174d[MainActivity]] ViewPostIme pointer 1
[WindowOnBackDispatcher] sendCancelIfRunning: isInProgress=falsecallback=androidx.activity.OnBackPressedDispatcher$Api34Impl$createOnBackAnimationCallback$1@6d5a864
[shellmemoryleak] Cleared Reference was only reachable from finalizer (only reported once)
[shellmemoryleak] Explicit concurrent mark compact GC freed 2603(200KB) AllocSpace objects, 0(0B) LOS objects, 58% free, 4403KB/10MB, paused 92us,1.888ms total 15.402ms
[shellmemoryleak] Explicit concurrent mark compact GC freed 1039(136KB) AllocSpace objects, 0(0B) LOS objects, 58% free, 4363KB/10MB, paused 71us,1.992ms total 13.601ms
[shellmemoryleak] Explicit concurrent mark compact GC freed 107(68KB) AllocSpace objects, 0(0B) LOS objects, 58% free, 4359KB/10MB, paused 98us,2.455ms total 16.666ms
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Information: ✅Label released
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Information: ✅LabelHandler released
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Information: ✅Label released
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Information: ✅LabelHandler released
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Information: ✅VerticalStackLayout released
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Information: ✅LayoutHandler released
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Information: ✅SecondPage released
[0:] MemoryToolkit.Maui.GarbageCollectionMonitor: Information: ✅PageHandler released
@AshokKumarVis96 AshokKumarVis96 added the t/bug Something isn't working label May 9, 2024
Copy link
Contributor

github-actions bot commented May 9, 2024

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@Zhanglirong-Winnie Zhanglirong-Winnie added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels May 9, 2024
@AshokKumarVis96
Copy link
Author

ShellMemoryLeak.zip

@Eilon Eilon added the area-controls-shell Shell Navigation, Routes, Tabs, Flyout label May 9, 2024
@Zhanglirong-Winnie
Copy link
Collaborator

Verified this issue with Visual Studio 17.10 Preview 6.0 (8.0.21 & 8.0.3). Can repro on iOS and android platforms with sample project.
image
We tried to use 8.0.0-rc.1.9171 in the sample project to verify this issue and encountered the following error:
image

@AshokKumarVis96
Copy link
Author

Verified this issue with Visual Studio 17.10 Preview 6.0 (8.0.21 & 8.0.3). Can repro on iOS and android platforms with sample project. -> Yes @Zhanglirong-Winnie

@AshokKumarVis96
Copy link
Author

We tried to use 8.0.0-rc.1.9171 in the sample project to verify this issue and encountered the following error: -> @Zhanglirong-Winnie Please try with Microsoft.Maui.Controls 8.0.3 version.

@PureWeen PureWeen added this to the Backlog milestone May 14, 2024
@PureWeen PureWeen added memory-leak 💦 Memory usage grows / objects live forever t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.) labels May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout memory-leak 💦 Memory usage grows / objects live forever platform/android 🤖 platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.)
Projects
None yet
Development

No branches or pull requests

5 participants