Conversation
| //https://github.com/dotnet/maui/issues/27411 | ||
| #endif | ||
| [InlineData(typeof(TabbedPage))] | ||
| public async Task PagesDoNotLeak(Type type) |
There was a problem hiding this comment.
This one is failing on Android Api Level 23:

Reference to Microsoft.Maui.Controls.NavigationPage (type Microsoft.Maui.Controls.NavigationPage is still alive.\nReference to androidx.fragment.app.FragmentContainerView{38d3432 V.E...... ......ID 0,0-1080,1773 #7f080142 app:id/nav_host} (type AndroidX.Fragment.App.FragmentContainerView is still alive.\n\n---- Assertion timed out
There was a problem hiding this comment.
If it works on newer emulators, you might just skip this test on API 23. It probably isn't a leak. There is at least one example of that in here somewhere.
|
/rebase |
3761b36 to
4fd7701
Compare
534d4bb to
42000ae
Compare
|
/rebase |
42000ae to
a6fead5
Compare
| if (m == 1) | ||
| { | ||
| GC.Collect(); | ||
| GC.Collect(2); |
There was a problem hiding this comment.
It's the number of "generations".
If making a higher number makes the test pass, this change is fine. 👍
But I would say we should move it to a single test utility method for all the tests to share.
There was a problem hiding this comment.
But, GC.Collect() should work better, because it will run on all generations. with 2 it will go from gen0 to gen2
jonathanpeppers
left a comment
There was a problem hiding this comment.
Can we make a TestUtilities.cs that all the tests share? Then for now a single method like:
public static async Task WaitForGC ()
{
await Task.Yield();
GC.Collect(2);
GC.WaitForPendingFinalizers();
}Then if you wanted to change the number 2 later (or other logic), it could be updated in one place.
| await Task.Yield(); | ||
| GC.Collect(); | ||
| GC.Collect(2); | ||
| GC.WaitForPendingFinalizers(); |
There was a problem hiding this comment.
Since there are many permutations of code like this littered thoughout the tests.
Can we make a single TestUtilities.cs file we can share between all the test projects? You shouldn't have to update so many files to introduce the number 2.
There was a problem hiding this comment.
It's a good approach to call GC.Collect() after GC.WaitForPendingFinalizers(); so the objects that had a finalizer will be collected.
Just a heads up, objects that have a Finalizer will need 2 collections to get collected, the first one it will be promoted to the next generation and will be referenced by the finalizer_queue until its Finalizer runs, then a second collection will collect those objects
|
|
Description of Change
Enable back comment out memory leak tests that were failing on Android on the net10.0 branch
Issues Fixed
Fixes #27411