O'Reilly logo

Xamarin 4.x Cross-Platform Application Development - Third Edition by Jonathan Peppers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

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 an image on Twitter, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required