From cbc9c442973ae5744ddcaed713e1910e3f293e82 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Tue, 9 Apr 2019 18:40:28 -0600 Subject: [PATCH] [Android] add another gc.collect for Android to ensure all is collected (#5847) * add another gc.collect for Android * move all gc collects to a helper --- .../Bugzilla31145.cs | 2 +- .../Bugzilla31255.cs | 2 +- .../Bugzilla32206.cs | 4 +--- .../Bugzilla32898.cs | 2 +- .../Bugzilla35132.cs | 3 +-- .../Bugzilla39489.cs | 3 +-- .../Bugzilla40955.cs | 4 +--- .../Bugzilla42069.cs | 4 +--- .../Bugzilla42329.cs | 4 +--- .../Bugzilla43941.cs | 3 +-- .../Bugzilla44047.cs | 4 +--- .../Bugzilla44166.cs | 3 +-- .../Bugzilla45722.cs | 3 +-- .../Bugzilla45722Xaml0.xaml.cs | 3 +-- .../Bugzilla45926.cs | 3 +-- .../Bugzilla51503.cs | 3 +-- .../Bugzilla55365.cs | 3 +-- .../Bugzilla57910.cs | 2 +- .../Helpers/GarbageCollectionHelper.cs | 16 ++++++++++++++++ .../Issue1023.cs | 4 +--- .../Issue1024.cs | 4 +--- .../Issue1703.cs | 4 ++-- .../Issue1895.cs | 4 +--- .../Issue2399.cs | 9 +++------ .../Issue5555.cs | 6 +++--- ...amarin.Forms.Controls.Issues.Shared.projitems | 3 ++- 26 files changed, 47 insertions(+), 58 deletions(-) create mode 100644 Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Helpers/GarbageCollectionHelper.cs 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 index 2fd9f9a43..d2e04b76d 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31145.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31145.cs @@ -43,7 +43,7 @@ namespace Xamarin.Forms.Controls.Issues { _resultLabel.Text = $"Page2 IsAlive = {_page2Tracker.IsAlive} ({n++})"; await Task.Delay(1000); - GC.Collect(); + GarbageCollectionHelper.Collect(); } _resultLabel.Text = $"Page2 IsAlive = {_page2Tracker.IsAlive}"; diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31255.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31255.cs index 896039cc8..a1f8718e6 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31255.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31255.cs @@ -53,7 +53,7 @@ namespace Xamarin.Forms.Controls.Issues ((Label)((StackLayout)Content).Children [0]).Text = string.Format ("Page1. But Page2 IsAlive = {0}", _page2Tracker.IsAlive); await Task.Delay (1000); - GC.Collect (); + GarbageCollectionHelper.Collect(); } } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32206.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32206.cs index 428538f64..a6c677e63 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32206.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32206.cs @@ -78,9 +78,7 @@ namespace Xamarin.Forms.Controls.Issues AutomationId = "GC", Command = new Command(o => { - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); + GarbageCollectionHelper.Collect(); Label.Text = "Counter: " + Counter; }) }, diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32898.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32898.cs index 727b167f1..02f63d142 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32898.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32898.cs @@ -71,7 +71,7 @@ namespace Xamarin.Forms.Controls.Issues while (_page2Tracker.IsAlive && _tabTracker.IsAlive && watch.ElapsedMilliseconds < Timeout) { await Task.Delay (1000); - GC.Collect (); + GarbageCollectionHelper.Collect(); } watch.Stop(); diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla35132.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla35132.cs index fddc247bb..714c183f9 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla35132.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla35132.cs @@ -63,8 +63,7 @@ namespace Xamarin.Forms.Controls.Issues async void Button_Clicked(object sender, EventArgs e) { Debug.WriteLine(">>>>>>>> Invoking Garbage Collector"); - GC.Collect(); - GC.WaitForPendingFinalizers(); + GarbageCollectionHelper.Collect(); await Navigation.PushAsync(new BugPage()); } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39489.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39489.cs index 1cc68facf..1a666d9e4 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39489.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39489.cs @@ -93,8 +93,7 @@ namespace Xamarin.Forms.Controls.Issues void GCbutton_Clicked(object sender, EventArgs e) { System.Diagnostics.Debug.WriteLine(">>>>>>>> Running Garbage Collection"); - GC.Collect(); - GC.WaitForPendingFinalizers(); + GarbageCollectionHelper.Collect(); System.Diagnostics.Debug.WriteLine($">>>>>>>> GC.GetTotalMemory = {GC.GetTotalMemory(true):n0}"); } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla40955.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla40955.cs index 543a4cab3..e98990f9a 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla40955.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla40955.cs @@ -131,9 +131,7 @@ namespace Xamarin.Forms.Controls.Issues protected override void OnAppearing() { base.OnAppearing(); - GC.Collect(); - GC.Collect(); - GC.Collect(); + GarbageCollectionHelper.Collect(); } } } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla42069.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla42069.cs index 989bbe7f9..272afc37b 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla42069.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla42069.cs @@ -53,9 +53,7 @@ namespace Xamarin.Forms.Controls.Issues var collectButton = new Button { Text = "Collect" }; collectButton.Clicked += (sender, args) => { - GC.Collect(); - GC.Collect(); - GC.Collect(); + GarbageCollectionHelper.Collect(); }; var startPage = new ContentPage diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla42329.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla42329.cs index 74ffbbfee..0a46e2268 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla42329.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla42329.cs @@ -145,9 +145,7 @@ namespace Xamarin.Forms.Controls.Issues protected override void OnAppearing() { base.OnAppearing(); - GC.Collect(); - GC.Collect(); - GC.Collect(); + GarbageCollectionHelper.Collect(); } } } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla43941.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla43941.cs index 9c6d9b09e..3af86369b 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla43941.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla43941.cs @@ -106,8 +106,7 @@ namespace Xamarin.Forms.Controls.Issues AutomationId = "GC", Command = new Command(o => { - GC.Collect(); - GC.WaitForPendingFinalizers(); + GarbageCollectionHelper.Collect(); Label.Text = "Counter: " + Counter; }) }, diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44047.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44047.cs index 7845013ed..139fcee96 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44047.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44047.cs @@ -44,9 +44,7 @@ namespace Xamarin.Forms.Controls.Issues { public Page2() { - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); + GarbageCollectionHelper.Collect(); Title = "Page2"; System.Diagnostics.Debug.WriteLine("Constructor"); diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44166.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44166.cs index 85c168c24..89f692496 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44166.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44166.cs @@ -26,8 +26,7 @@ namespace Xamarin.Forms.Controls.Issues var gcButton = new Button { Text = "GC", AutomationId = "GC" }; gcButton.Clicked += (sender, args) => { - GC.Collect(); - GC.WaitForPendingFinalizers(); + GarbageCollectionHelper.Collect(); if (_44166MDP.Counter > 0) { diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45722.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45722.cs index 200929115..53265ba79 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45722.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45722.cs @@ -98,8 +98,7 @@ namespace Xamarin.Forms.Controls.Issues var collect = new Button() { Text = Collect }; collect.Clicked += (sender, args) => { - GC.Collect(); - GC.WaitForPendingFinalizers(); + GarbageCollectionHelper.Collect(); }; Title = "Bugzilla 45722"; diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45722Xaml0.xaml.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45722Xaml0.xaml.cs index 25afd5547..4ca1cffbf 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45722Xaml0.xaml.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45722Xaml0.xaml.cs @@ -45,8 +45,7 @@ namespace Xamarin.Forms.Controls.Issues GCButton.Clicked += (sender, args) => { - GC.Collect(); - GC.WaitForPendingFinalizers(); + GarbageCollectionHelper.Collect(); }; MessagingCenter.Subscribe<_45722Label>(this, _45722Label.CountMessage, sender => diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45926.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45926.cs index 4427f3909..e1130f9eb 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45926.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45926.cs @@ -51,8 +51,7 @@ namespace Xamarin.Forms.Controls.Issues }; doGC.Clicked += (sender, e) => { - GC.Collect (); - GC.WaitForPendingFinalizers(); + GarbageCollectionHelper.Collect(); instanceCount.Text = $"Instances: {_45926SecondPage.InstanceCounter.ToString()}"; messageCount.Text = $"Messages: {_45926SecondPage.MessageCounter.ToString()}"; }; diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla51503.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla51503.cs index 875d134cc..37a98e17f 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla51503.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla51503.cs @@ -36,8 +36,7 @@ namespace Xamarin.Forms.Controls.Issues async void Button_Clicked(object sender, EventArgs e) { - GC.Collect(); - GC.WaitForPendingFinalizers(); + GarbageCollectionHelper.Collect(); await Navigation.PushAsync(new ChildPage()); } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla55365.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla55365.cs index 1ab99a2ed..161c9657f 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla55365.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla55365.cs @@ -52,8 +52,7 @@ namespace Xamarin.Forms.Controls.Issues var collectButton = new Button { Text = "Garbage", Command = new Command(o => { - GC.Collect(); - GC.WaitForPendingFinalizers(); + GarbageCollectionHelper.Collect(); _layout.Children.Add(new Label {Text = "Success"}); }) }; _layout.Children.Add(collectButton); diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla57910.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla57910.cs index ffc9eb931..5c7af0388 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla57910.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla57910.cs @@ -41,7 +41,7 @@ namespace Xamarin.Forms.Controls.Issues async void Button_Clicked(object sender, EventArgs e) { await Navigation.PushAsync(new ListPage()); - GC.Collect(); + GarbageCollectionHelper.Collect(); } } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Helpers/GarbageCollectionHelper.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Helpers/GarbageCollectionHelper.cs new file mode 100644 index 000000000..f5a429960 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Helpers/GarbageCollectionHelper.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Xamarin.Forms.Controls.Issues +{ + public static class GarbageCollectionHelper + { + public static void Collect() + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + } + } +} diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1023.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1023.cs index a09a49a0a..e1c27dcf8 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1023.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1023.cs @@ -78,9 +78,7 @@ namespace Xamarin.Forms.Controls.Issues AutomationId = "GC", Command = new Command(o => { - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); + GarbageCollectionHelper.Collect(); Label.Text = "Counter: " + Counter; }) }, diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1024.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1024.cs index f62369c7c..20744dea1 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1024.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1024.cs @@ -78,9 +78,7 @@ namespace Xamarin.Forms.Controls.Issues AutomationId = "GC", Command = new Command(o => { - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); + GarbageCollectionHelper.Collect(); Label.Text = "Counter: " + Counter; }) }, diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1703.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1703.cs index ec9bf170a..eaf2569fc 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1703.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1703.cs @@ -25,14 +25,14 @@ namespace Xamarin.Forms.Controls.Issues static Page CreateWeakReferencedPage() { - GC.Collect(); + GarbageCollectionHelper.Collect(); var result = CreatePage(); s_pageRefs.Add(new WeakReference(result)); // Add a second unreferenced page to prove that the problem only exists // when pages are actually navigated to/from s_pageRefs.Add(new WeakReference(CreatePage())); - GC.Collect(); + GarbageCollectionHelper.Collect(); return result; } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1895.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1895.cs index ce0b31133..926c3b212 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1895.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1895.cs @@ -26,9 +26,7 @@ namespace Xamarin.Forms.Controls.Issues static Page CreateWeakReferencedPage() { - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); + GarbageCollectionHelper.Collect(); var result = CreatePage(); s_pageRefs.Add(new WeakReference(result)); diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2399.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2399.cs index 51160537b..0ec91f0ac 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2399.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2399.cs @@ -50,8 +50,7 @@ namespace Xamarin.Forms.Controls.Issues Text = "Garbage Collection Things", Command = new Command(() => { - GC.Collect(); - GC.WaitForPendingFinalizers(); + GarbageCollectionHelper.Collect(); AttachedStateEffects.Clear(); }), }, @@ -76,16 +75,14 @@ namespace Xamarin.Forms.Controls.Issues // needed otherwise UWP crashes await Task.Delay(100); await Navigation.PopAsync(); - GC.Collect(); - GC.WaitForPendingFinalizers(); + GarbageCollectionHelper.Collect(); } void OnAllEventsDetached(object sender, EventArgs args) { AttachedStateEffects.Clear(); AttachedStateEffects.AllEventsDetached -= OnAllEventsDetached; - GC.Collect(); - GC.WaitForPendingFinalizers(); + GarbageCollectionHelper.Collect(); AllEffectsHaveDetached.Text = "Success"; } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5555.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5555.cs index c38832b74..0fc76b458 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5555.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5555.cs @@ -59,6 +59,8 @@ namespace Xamarin.Forms.Controls.Issues result.Text = "Click 'Push page' again"; return; } + + GarbageCollectionHelper.Collect(); result.Text = list[list.Count - 2].IsAlive ? "Failed" : "Success"; }) }; @@ -76,9 +78,7 @@ namespace Xamarin.Forms.Controls.Issues await Navigation.PushAsync(page); await page.Navigation.PopAsync(); - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); + GarbageCollectionHelper.Collect(); list.Add(wref); if (list.Count > 1) diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index e0766d8a1..a1e6c59cc 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -9,6 +9,7 @@ Xamarin.Forms.Controls.Issues + @@ -1157,4 +1158,4 @@ MSBuild:UpdateDesignTimeXaml - + \ No newline at end of file