Avoiding common memory pitfalls
Memory on mobile devices is certainly not an unlimited commodity. Because of this, memory usage in your application can be much more important than on desktop applications. At times, you might find the need to use a memory profiler, or improve your code to use memory more efficiently.
The following are the most common memory pitfalls:
- The garbage collector (GC) is unable to collect large objects fast enough to keep up with your application
- Your code inadvertently causes a memory leak
- A C# object is garbage collected but is later attempted to be used by native code
Garbage collector
Let's take a look at the first problem where the GC cannot keep up. Let's say we have a Xamarin.iOS application with a button for sharing ...
Get Xamarin: Cross-Platform Mobile Application Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.