O'Reilly logo

Xamarin Essentials by Mark Reynolds

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

Garbage collection

Since Xamarin.Android apps run in two different VMs, garbage collection is somewhat complex and creates some interesting challenges. Therefore, we have devoted significant time to discuss this process. Xamarin.Android uses Mono's simple generational garbage collector, which supports two types of collections called minor and major:

  • Minor collections: These collections are cheap and thus invoked frequently. Minor collections collect recently allocated and dead objects and are invoked after every few MB of allocations. You can manually invoke a minor collection with the following code:
    GC.Collect(0)
  • Major collections: These collections are expensive and are thus invoked less frequently. Major collections reclaim all dead objects and ...

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