diff options
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31145.cs')
-rw-r--r-- | Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31145.cs | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31145.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31145.cs new file mode 100644 index 00000000..9e1d7916 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31145.cs @@ -0,0 +1,67 @@ +using System; +using System.Threading.Tasks; +using Xamarin.Forms.CustomAttributes; + +namespace Xamarin.Forms.Controls +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Bugzilla, 31145, "Picker cause memory leak holding entire Page in memory after it popped (WP8 SL only)", PlatformAffected.WinPhone)] + public class Bugzilla31145 : TestContentPage + { + WeakReference _page2Tracker; + Label _resultLabel; + + protected override void Init() + { + var instructions = new Label () { Text = "The counter below should say 'Page2 IsAlive = false' after a short period of time. If the counter does not say that within 5 seconds, this test has failed." }; + _resultLabel = new Label (); + Content = new StackLayout { Children = { instructions, _resultLabel } }; + } + + protected override async void OnAppearing() + { + base.OnAppearing(); + + if (_page2Tracker == null) + { + var page2 = new Bugzilla31145Page2(); + + _page2Tracker = new WeakReference(page2, false); + + await Task.Yield(); + await Navigation.PushModalAsync(page2); + + StartTrackPage2(); + } + } + + async void StartTrackPage2() + { + var n = 0; + while (_page2Tracker.IsAlive) + { + _resultLabel.Text = $"Page2 IsAlive = {_page2Tracker.IsAlive} ({n++})"; + await Task.Delay(1000); + GC.Collect(); + } + + _resultLabel.Text = $"Page2 IsAlive = {_page2Tracker.IsAlive}"; + } + } + + public class Bugzilla31145Page2 : ContentPage + { + public Bugzilla31145Page2() + { + Content = new Picker(); + } + + protected override async void OnAppearing() + { + base.OnAppearing(); + + await Task.Yield(); + await Navigation.PopModalAsync(); + } + } +}
\ No newline at end of file |