Chapter 2. Memory Management
This chapter investigates how memory is managed on iOS and Android with Xamarin runtime. Whilst drawing parallels to the .NET platform, it will provide examples of memory management problems and issues that can cause leaks, and also look at useful patterns that can help developers save valuable resources. This chapter is divided into the following sections:
- Application Component lifecycle
- Garbage collection
- Platform-specific concepts
- Troubleshooting and diagnosis
- Patterns and best practices
Application Component lifecycle
Each platform in the Xamarin ecosystem has certain processes and states that the applications go through during their execution lifetime. Developers can implement certain methods and subscribe to lifecycle events such as application start, suspension, termination, and backgrounding to handle much needed application state and release resources which are no longer required.
Activity lifecycle (Android)
In Android applications, contrary to the...