-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathBugzilla31255.cs
86 lines (70 loc) · 1.72 KB
/
Bugzilla31255.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
namespace Maui.Controls.Sample.Issues
{
[Issue(IssueTracker.Bugzilla, 31255, "Flyout's page Icon cause memory leak after FlyoutPage is popped out by holding on page")]
public class Bugzilla31255 : NavigationPage
{
public Bugzilla31255() : base(new MainPage())
{
}
public class MainPage : ContentPage
{
public MainPage()
{
var stack = new StackLayout() { VerticalOptions = LayoutOptions.Center };
stack.Children.Add(new Label()
{
VerticalOptions = LayoutOptions.Center,
HorizontalTextAlignment = TextAlignment.Center,
Text = "Page 1",
AutomationId = "MauiLabel"
});
Content = stack;
}
WeakReference _page2Tracker;
protected override async void OnAppearing()
{
base.OnAppearing();
if (_page2Tracker == null)
{
var page2 = new Page2();
_page2Tracker = new WeakReference(page2, false);
await Task.Delay(1000);
await Navigation.PushModalAsync(page2);
StartTrackPage2();
}
}
async void StartTrackPage2()
{
while (true)
{
((Label)((StackLayout)Content).Children[0]).Text =
string.Format("Page1. But Page2 IsAlive = {0}", _page2Tracker.IsAlive);
await Task.Delay(1000);
GarbageCollectionHelper.Collect();
}
}
public class Page2 : FlyoutPage
{
public Page2()
{
Flyout = new ContentPage
{
Title = "Flyout",
IconImageSource = "Icon.png"
};
Detail = new ContentPage() { Title = "Detail" };
}
protected override async void OnAppearing()
{
base.OnAppearing();
await Task.Delay(1000);
await Navigation.PopModalAsync();
}
protected override void OnDisappearing()
{
base.OnDisappearing();
}
}
}
}
}