What does Xamarin.iOS do with memory management when compiling C # to native code?

What does Xamarin.iOS do for memory management? With regular IL, we have a Garbage Collector that takes care of idle objects and programmer reliefs from calling delete. How does it work when Xamarin compiles the code in native? Who cleans objects that are no longer in use?

This question answers how compilation works, but does not explain the memory management part: How does MonoTouch work?

+6
source share
1 answer

The answer you are looking for was indicated on the question that you related.

To summarize, the IL-to-native translation process is done in advance, but other parts of the Mono runtime are still required. Compiling JIT is only one of the tasks performed by the runtime, and this part is incompatible with iOS memory restrictions (pages with writeability to memory cannot be executable either, and this is necessary for JIT to work). This is AFAIK, the only reason compile-ahead compilation (AOT) is required at all.

The Mono garbage collector really works on iOS; it is simply embedded in the binary created by the Monotouch compiler. The resulting binary contains your AOT-compiled application code, as well as AOT-compiled versions of the libraries you use and a reduced version of the Mono runtime.

+6
source

All Articles