Mono IOS be rather baffling flash solution back

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

The use of mono IOS development for one year, have a headache is flash back, but when the flash back and not thrown clear error.

Two days ago, when debugging a bug, the serialization and be rather baffling flash back, then in a great (blog) guidance, found the solution!

The flash back, generally in the Application output output error is as follows:

    ............
    0x01e394ac monoeg_g_log + 208 6 TrackAboutIOS
    0x01d11664 get_numerous_trampoline + 160 7 TrackAboutIOS
    ............
    =================================================================
          Got a SIGSEGV while executing native code. This usually indicates
           a fatal error in the mono runtime or one of the native libraries 
          used by your application.
   =================================================================

But this error is random, sometimes normal, sometimes is not normal, in the above output error we see the word "trampoline", but the first monoeg_g_log this sentence mean system in trying to record error to the error log, based on this case, we can determine which is the default on mono (Trampoline) number less than the application of the required number of trampoline you.

A number of explanations of trampoline, here Rolf Bjarne Kvinge to the corresponding explanation: the appropriate link

On device we generate all the necessary code at build time in a process known as Ahead of Time compilation (similar to Microsoft's ngen), because we're not allowed to jit code on devices. Unfortunately there are a few things that cannot be determined statically - for instance generic interfaces might need different vtables depending on which type the interface is instantiated with. (For this case it is technically possible to determine the maximum number of vtables, but the number would be potentially enormous - multiply the number of generic interfaces times the number of types in your app...). We cannot allocate memory for these vtables dynamically at runtime, so we've picked a reasonable default and allow the user to increase this value if they run into issues. This is the basic theory for the trampolines (the exact problem is a bit different, depending on the type of trampolines, but that's not really important).

So you can add as many trampolines as you want, but memory usage will increase. That's also all there is to it: the app will not get slower (unless if the increased memory usage causes it to run slower, due to out-of-memory warnings, etc). It also means that you only have to increase the number of trampolines of the type you're actually having problems with, if you increase the others you'll increase the size of your executable needlessly.
 

It is (not good at English, try to translate.):

Because mono is not allowed in the Apple device JIT compiled code, so the mono at compile time by AOT compiler technology directly compiled into assembly code ARM. But there are still some things cannot be determined statically at compile time: such as generic interface may need different (virtual table set execution method stored in operation), depending upon the type of interface is instantiated in. (in this case, technically to determine the maximum number of virtual table is possible, but this number may be large --The generic interface number multiplied by the application number)...... We cannot allocate memory for these virtual table dynamically at runtime, so we specify a reasonable default and allow the user to the case of a problem to increase the default values at run time. This is the basic theory of Trampoline (the actual situation slightly different, depending on the trampoline number type, but it is not important)

So you can according to your needs as much as possible to increase the number of trampoline, but memory will increase the use of. Applications are generally not slow (unless the memory usage has led to the rise of memory, thus causing running slow). It also means that you only need to increase the problems that block corresponding to the number of types of trampoline. If you increase the number of other trampoline type, you will not need to increase the volume. 

After reading this, I want you to have a certain understanding of the trampoline, that how to set up.!

Open the xamarin studio project file, right click on option, spread below, in arguments parameters, input: -aot "nrgctx-trampolines=4096" -aot "nimt-trampolines=4096" -aot "ntrampolines=4096"

Please see below:

QQ图片20130906181222

We saw the -aot " on nrgctx-trampolines=4096" -aot; " nimt-trampolines=4096" -aot " ntrampolines=4096" these input parameters, the parameters corresponding to what is the meaning of this?

Here's to our interpretation: the link address

Ran out of trampolines of type 0
If you get this message while running device,  You can create more type 0 trampolines (type SPECIFIC) by modifying your project options "iPhone Build" section.  You want to add extra arguments for the Device build targets:

-aot "ntrampolines=2048"

The default number of trampolines is 1024.  Try increasing this number until you have enough for your application.

Ran out of trampolines of type 1
If you make heavy use of recursive generics, you may get this message on device.  You can create more type 1 trampolines (type RGCTX) by modifying your project options "iPhone Build" section.  You want to add extra arguments for the Device build targets:

-aot "nrgctx-trampolines=2048"

The default number of trampolines is 1024.  Try increasing this number until you have enough for your usage of generics.

Ran out of trampolines of type 2
If you make heavy use interfaces, you may get this message on device.  You can create more type 2 trampolines (type IMT Thunks) by modifying your project options "iPhone Build" section.  You want to add extra arguments for the Device build targets:

-aot "nimt-trampolines=512"

The default number of IMT Thunk trampolines is 128.  Try increasing this number until you have enough for your usage of interfaces.

The following translation:

Ran out of trampolines of type 0 
If you run, the output of the error, you can add additional parameter -aot in project option--iphone build. "ntrampolines=2048" 
This parameter is the default value is 1024, try increasing this value until you meet the application requirements. 
Ran out of trampolines of type 1 
If a generic nested, you use too much like List<T> and List<T> member, you can add additional parameters by -aot. "nrgctx-trampolines=2048" To solve the. 
Trampoline type 1 the default is 1024
Ran out of trampolines of type 2 
If you interface operation frequently, you can add additional parameter -aot "nimt-trampolines=512" To solve the. 
The default value is 128.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Lucy at November 17, 2013 - 9:38 AM