Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should I enable “reference counting extension” in MonoTouch build settings?

In what circumstances should I be using this feature?
How exactly mature is it?

What are the pros and cons?
What problem does it solve?

Is it specific to MonoTouch, Mono GC, or reference counting in ObjC?

enter image description here

like image 476
Dan Abramov Avatar asked Oct 22 '12 10:10

Dan Abramov


1 Answers

Here are some quick, high-level (and out or order) answers to your questions...

Is it specific to MonoTouch, Mono GC, or reference counting in ObjC?

It allows sgen, the mono garbage collector, to work more closely with Objective-C reference counting. That awareness is not needed for Mono (or Mono for Android) so it's specific to MonoTouch.

How exactly mature is it?

As the UI says: Experimental preview. So while we know it works it has not yet seen a wide usage inside applications (compared to the default GC). It's more a direction than a destination (i.e. it will likely evolve).

You're more than welcome to test it, use it (if it proves useful in your situation) and report your findings/experiences with it. However it's not fully supported, e.g. you might hit a bug that we can't immediately fix or workaround (beside asking you to go back to the default settings).

What problem does it solve?

The coexistence of a garbage collector and the reference counting of Objective-C is very complex subject. MonoTouch tries it best to hide (most of) complexity of this to the developers.

Most of this is done inside the runtime (e.g. by using the backing fields). This extension to sgen is meant to have the GC itself (not only the runtime) aware of the needs for reference counting.

What are the pros and cons?

PRO: It saves memory as the linker can remove many of the backing fields that would be otherwise required to ensure we keep a reference to the managed objects. Without those (references to) backing fields the GC would normally collect the instances (while they are still needed by unmanaged code).

CON: We need more feedback, more comparison data (e.g. performance).

like image 97
poupou Avatar answered Nov 15 '22 20:11

poupou