MyPage is a personalized page based on your interests.The page is customized to help you to find content that matters you the most.


I'm not curious

How To Avoid Memory leaks in Xamarin Forms

Published on 13 January 17
0
1
Introduction

Memory leaks in one of the major problem nowadays with the mobile applications, a good mobile app will consume less memory of the device because mobile device having limited memory and processing capabilities as compared with the system. Memory plays the major role while the application is running on the mobile device, a good application is always clears the memory once the page is not in use, with Xamarin Forms it is very difficult to manage the memory while the application is running.

There are certain factors which cause the memory leaks in the mobile application,

  1. Images
  2. Background Thread
  3. Multiple instances of objects/class
  4. Using more static objects/classes
  5. not clearing database (SQL Lite) while logout etc.

All the above factors are responsible for the memory leaked in mobile application, which may cause crashes or app will perform slow. There are various approaches which will help mobile apps to release the memory from its cache and prevent application from crashes.

Solution

There are many techniques which helps mobile app to improve the performance and avoid the memory leaks, some of them we are going to see,

It will impact on the performance of the application,


a. When we are navigating form one page to another we need to use below points as best development practices in mobile,
  • Clear / set null the collection

sampleViewModel.sampleObservableCollection = null;

Or you can also use,