Enlighten the Xamarin Memory Profiler Object

I have a large Xamarin iOS app that suffers from accidental crashes - which I think is due to memory issues. Before trying to fix the problems, I try so that I fully understand how to properly manage everything, so I created a very simple sample application with UINavigationController2 screens:

Storyboard layout

My idea was to use the profiler to verify that I cleaned everything correctly after use, so I:

  • Run my profiler application
  • Created a snapshot as soon as everything loaded. (strange I have to click 3 times before the object grows to 0)
  • I clicked the button “Shows the next screen” and took a picture 4.
  • Press the back button and then take a picture 5.

, 5 4, , . , , 369 :

Xamarin Profiler Results

dispose Screen2ViewController, , , :

public partial class Screen2ViewController : UIViewController
    {
        public override void ViewDidDisappear (bool animated)
        {
            base.ViewDidDisappear (animated);

            this.Dispose ();
        }
        public Screen2ViewController (IntPtr handle) : base (handle)
        {
        }

        partial void GoBackButton_TouchUpInside (NSObject sender)
        {
            this.NavigationController.PopViewController(true);
        }

        protected override void Dispose (bool disposing)
        {
            this.ReleaseDesignerOutlets ();
            this.View.Dispose ();
            base.Dispose (disposing);
        }
    }

, , , , 0? , , ?

this.ReleaseDesignerOutlets() ? , , Dispose.

+4
2

SO post.

, -, . , . , , GC.Collect() .

:

+2

, , , , .

, . , - , , , .

+1

Source: https://habr.com/ru/post/1611123/


All Articles