Ran out of trampolines of type 2 - iOS

When running our game on iOS (have tested both on iPhone 3G and iPhone 4) we are getting a consistent crash with the following error:

Ran out of trampolines of type 2 in ‘/private/var/mobile/Applications//.app/Data/Managed/mscorlib.dll’ (128)

The crash is not linked to any specific line of code as rearranging the code causes the crash after a certain number of operations occur, not the operations themselves.

The best answer I can find is here stating: I need to add this to the arguments for monotouch “-aot “nimt-trampolines=2048””. However I can’t pass this argument when using Unity can I?

I just received a reply from Unity:

“This is a known problem with Generics. In the next release of Unity we will expose the aot options in the player settings that will allow you to change that parameter.”

what are trampolines and how best to avoid this issue? what were you doing? I have to ship now, I cannot way till the future, so how best to avoid it?

It looks to be related to heavy C# Generics use. Some people get it from using LINQ, we just have a complex codebase that makes heavy use of generic classes, interfaces, etc. I’ve asked for an ETA on the fix, I’ll post if I get one.

PM me your email if you’d like to talk in more detail.

Hello there. I have the same problem but I don’t use LINQ or complex generic code. Is there concrete reason of this exception? I have many interfaces in my project. May it be reason? And could anybody explain me what are trampolines and how they used by aot compiler? Thanks

See http://answers.unity3d.com/questions/64909/ran-out-of-trampolines-of-type-2-ios.html

I have solved it using

Player Settings > Other Settings and set the AOT option to nimt-trampolines=512 (or perhaps more)