title: Is reference counting method no longer used for Xamarin.iOS in Xamarin.Forms 2.4.0 and above nugget?
body: <p>I have been developing Xamarin since XF 1.0. Memory leak was a huge problem from XF 1.0 till now XF 2.4. I have always been implementing Dispose Pattern in all my ContentPage and ViewModel classes to make sure Event handlers, Message Subscribers, object references are all removed and set to null either in OnDisappearing() or in Dispose() function of each class. </p>
  
  <p>Here is something very intriguing. After I upgraded my project to Xamarin.Forms 2.4.0.280 from 2.3.3.180. I found out this type of code that used to create memory leak in Xamarin.iOS no longer occur.
  Code Example: </p>
  
  <pre><code>public partial class ContactUsPage : ContentPage
  {
      public ContactUsPage ()
      {
          InitializeComponent ();
      }
  
      protected override void OnAppearing ()
      {
          //Lets say I have button named "btn" declared in Xaml page
          btn.Clicked += OnButtonClicked
  
          MessagingCenter.Subscribe&lt;CoreMessenger, string&gt;(this, "AMessageType", (sender, arg) =&gt;
          {
              //some code 
          });
      }
  
      protected override void OnDisappearing ()
      {
          //btn.Clicked -= OnButtonClicked
          //MessagingCenter.Unsubscribe&lt;CoreMessenger, string&gt;(this, "AMessageType");
      }
  }
  </code></pre>
  
  <p>Prior to Xamarin.Forms 2.4, If we Push and Pop this page as a Modal multiple time, we will see multiple instances of this page persist in memory and will never be Garbage Collected due to Event Handler and Subscriber are not removed and they created object references pointing back to the ContactUsPage instances, unless we uncomment the code in OnDisappearing () function.</p>
  
  <p>The above code no longer creates memory leak in Xamarin iOS when compiled in Xamarin.Forms 2.4.0.280, although it is clearly leaking memory according to my knowledge of how reference counting garbage collection works. Did Xamarin change the GC method for Xamarin.iOS? So it is doing mark-and-sweep like Xamarin.Android now?</p>
  
  <p>Can someone tell me what changed and why?
  Thanks a ton!</p>