Open Zack-G-I-T opened 5 days ago
We've found some similar issues:
If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.
Note: You can give me feedback by 👍 or 👎 this comment.
Hi we have the same issues and despite what we do we have memory leaks - I would expect my pages marked as transient to be cleaned up. Any advice? @jonathanpeppers , is this because of https://github.com/dotnet/maui/issues/8538.
Are you also using IDisposable
on those transient pages?
I am not a fan of DI, in general, so I might not be best to comment about its usage. 😄
@jonathanpeppers Yes I am using DI and I am using Idisposable on those transient pages but they get not cleaned up either.
I think the current behavior is that transient IDisposable
won't go away, but @PureWeen might know more details.
Yea, that's how IDisposable
works by default with MSFT dependency Injection.
Hi @Zack-G-I-T. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Description
We are having some memory issues in our app where the app gets slower after some time and noticed in a gcdump file that all our pages have multiple counts.
We created a dummy project with a second transient page, and added a buton with a method to go back, and call dispose method as well. However in the gcdump there are still multiple counts of this page.
Our question is how are transient pages managed in .NET MAUI? We tested in .net 8 and 9 Transient View/ViewModels are not cleaned up.
How do static variables affect memory management in .NET MAUI? If I am injecting a Singleton Service into a ViewModel will this be cleaned up or also the service has to be transient?
This is a basic default project with no viewmodels and minimal dependency injection, so what is causing the page to be kept in memory?
Steps to Reproduce
Link to public reproduction project repository
https://github.com/Zack-G-I-T/MauiMemoryIssue
Version with bug
9.0.0-rc.2.24503.2
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
No response