Before you begin
This is a cross-platform class which primarily focuses on Xamarin.Android and Xamarin.iOS. To fully complete the coding exercises, you will need both development environments with either a simulator/emulator or devices to run the exercise on. Please see the setup page if you need help installing the Xamarin development environment.
Overview
In this class, we will look at specific techniques to identify memory issues in our managed applications and then turn to specific Xamarin.iOS and Xamarin.Android issues that many applications encounter.
Objectives
- Identify and fix memory leaks in your code
- Recognize and fix Xamarin.iOS specific memory problems
- Recognize and fix Xamarin.Android specific memory problems
Lecture
XAM370 - Diagnosing Memory Management Issues.
Exercises
Exercise materials are available from GitHub. The code can be cloned through a desktop Git client or downloaded directly as a ZIP file.
- Using the Xamarin Profiler to monitor allocationsDemonstration
In this demonstration, we will examine an application and watch it's memory allocation to identify some potential improvements we can make in the code. - Finding and fixing delegate reference leaksExercise
In this exercise, we will track down a memory leak in a Xamarin.Forms application which is caused by an event handler. - Identifying and breaking strong reference cyclesExercise
In this group exercise, we will troubleshoot and fix a Xamarin.iOS application which has a reference cycle that causes a memory leak. - Watch out for peer promotionsExercise
In this group exercise, we will fix a case where Xamarin.iOS holds onto a view reference due to a framework peer promotion. - Show ListView memory and performance with a custom adapterDemonstration
In this final demonstration, we will troubleshoot and fix some performance issues with an Android application which utilizes aListView
.