使用mono进行ios开发也有一年了,一直有个头疼的问题是闪退,而且闪退的时候并没有抛出明确的错误。

前两天在调试一个bug的时候,在序列化的时候又莫名其妙的闪退,后来在一位大神(博客地址)的指导下,发现了解决方案!

遇到这种闪退,一般在Application output中输出错误如下:

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

而且这种错误是随机的,有时候正常运行,有时候不正常,在上文输出错误内容里我们看到trampoline这个单词,而第一句monoeg_g_log 这句话是说系统在尝试记录错误到错误日志,基于这种情况下,我们可以判定这是mono的默认蹦床(trampoline)数小于了你应用需要的蹦床数。

关于蹦床数的解释,这里Rolf Bjarne Kvinge给了相应的解释:相应链接

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.

大体意思是(英语不大好,尽力翻译了):

因为mono不允许在苹果设备上即时编译代码,所以在编译的时候mono会通过AOT编译技术直接编译为ARM汇编代码。但在编译的时候仍有一些无法静态确定的事情:例如泛型接口可能需要不同的虚拟表(运行时存放执行方法的集合),这取决于接口被实例化时的类型。(对于这种情况,从技术上讲确定虚拟表的最大数量是可能的,但是这数量可能会是庞大的--即泛型接口数乘以应用中类型数)……我们无法为这些虚拟表在运行时动态的分配内存,所以我们指定了一个合理的默认值并且允许用户在运行时出现问题的情况下增加默认值。这就是蹦床的基本理论(实际情况略微不同,这依赖于蹦床数的类型,但这并不重要)所以你可以按你的需要尽可能的增加蹦床数,但是内存的使用会增加。 应用一般不会变慢(除非内存的使用增多导致了内存不足,从而引起运行变慢)。这也同时意味着你只仅仅需要增加发生问题那块对应的蹦床类型的数目。如果你增加了其他蹦床类型的数目,你也会不必要的增多了执行的体积。

看完这个,我想你对蹦床数有了一定了解,那如何设置呢!

打开xamarin studio ,在项目文件上右键option,展开下图,在arguments参数的地方,输入:-aot "nrgctx-trampolines=4096" -aot "nimt-trampolines=4096" -aot "ntrampolines=4096"

请看下图:

我们在上面看到了-aot "nrgctx-trampolines=4096" -aot "nimt-trampolines=4096" -aot "ntrampolines=4096"这几个输入参数,那这几个参数相对应的意思是什么呢?

这里官网给了我们解释:链接地址

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.

下面进行翻译一下:

Ran out of trampolines of type 0
如果你再运行时,输出这个错误,你可以在项目option--iphone build处添加额外的参数-aot "ntrampolines=2048"
这个参数默认值为1024,试着增加这个值直到满足你的应用的需求。
Ran out of trampolines of type 1
如果你使用了过多的泛型嵌套,如List<T>中还有List<T>成员,你可以同上通过添加额外的参数-aot "nrgctx-trampolines=2048" 来解决。
蹦床类型1的默认值为1024.
Ran out of trampolines of type 2
如果你界面操作频繁,你可以通过添加额外的参数-aot "nimt-trampolines=512" 来解决。
这里的默认值为128.





http://www.51mono.com/article/show/188

ios莫名其妙闪退的解决方法相关推荐

  1. wind10MySQL闪退什么密码_win10系统Mysql输入密码后闪退的解决方法

    win10系统Mysql输入密码后闪退的问题发生概率较高.怎样来处理win10系统Mysql输入密码后闪退的问题,知道的人估计不多.本站针对win10系统Mysql输入密码后闪退的情况总结了一些解决的 ...

  2. 关于PS插件Nik Collection不兼容cc2021闪退的解决方法

    Adobe CC 更新到2021后,有不少小伙伴都发现了一个问题,之前能用的好几个Nik插件,现在都用不了了!调完一张照片尝试保存更改时,结果会让PS闪退关闭.这就让许多摄影师和设计爱好者们感到十分的 ...

  3. HDFView 3.1.2 在WIN10系统安装后打开出现黑框闪退的解决方法

    HDFView 3.1.2 在WIN10系统安装后打开出现黑框闪退的解决方法 HDF文件是美国国家高级计算中心为了满足各种领域研究需求而研制的一种能高效存储和分发科学数据的新型数据格式.HDFView ...

  4. pdfwin10闪退_win10系统打开文件夹闪退的解决方法

    今天小编给大家分享的是Win10系统打开文件夹闪退的解决方法,使用win10系统过程中,有时会遇到打开桌面文件夹就一直出现闪退的故障,为此问题困扰的用户,可参照以下的方法进行解决. 更新win10版本 ...

  5. Tomcat8 安装后点击startup出现闪退的解决方法(转)

    Tomcat8 安装后点击startup出现闪退的解决方法(转) 参考文章: (1)Tomcat8 安装后点击startup出现闪退的解决方法(转) (2)https://www.cnblogs.co ...

  6. win11打开控制面板闪退怎么办 Windows11控制面板闪退的解决方法

    一说到控制面板,相信大家都不陌生,因为平时电脑的很多设置都在这里面设置的,但是最近有用户反映自己在win11当中打开控制面板后出现闪退的情况,那么我们遇到win11控制面板闪退怎么办呢,下面,小编就把 ...

  7. win10打开计算机管理闪退,win10系统下任务管理器闪退的解决方法

    任务管理器想必大家都很熟悉吧,当遇到程序停止运行未响应的时候就可以通过任务管理器来关闭,可是有win10系统用户在使用任务管理器的时候出现了闪退的情况,该怎么办呢,本文就给大家讲解一下win10系统下 ...

  8. win10玩武装突袭3一会就闪退的解决方法

    很多玩家们在使用win10正式版系统玩武装突袭3(arma3)时,会出现游戏闪退.崩溃的情况,很是影响游戏的体验,我们要怎么解决这一情况呢?没关系,下面小编就来为大家分享关于win10玩武装突袭3一会 ...

  9. 方舟服务器掉线就无响应,方舟适者生存闪退重启解决方法 怎么连接进入服务器?...

    方舟适者生存闪退重启解决方法 怎么连接进入服务器? 2016-03-19 13:23:40来源:贴吧编辑:评论(0) <方舟:适者生存>中有些玩家连接服务器后出现闪退重启的问题,如何解决? ...

最新文章

  1. 解决tensorflow报错ValueError: Variable conv1/weights already exists, disallowed.
  2. 如何修炼成某一领域的高手
  3. android之 实现对搜索框输入内容(自动出现匹配内容)
  4. oracle 方言报错,ORACLE11g:No Dialect mapping for JDBC type: -9解决方案详解
  5. java基础提升篇:Java中Native关键字的作用
  6. php 检查字符串类型,PHP之字符串类型与检验
  7. 【安卓开发 】Android初级开发(五)自定义View
  8. 【CSS3】填色表格演示hsl()
  9. 【转】Burp Suite详细使用教程-Intruder模块详解
  10. linux内存管理总结
  11. Bootloader之BareBox 之路(1)--安装
  12. LCD直流数显多功能电压电流功率表电压电流表电量量产资料
  13. vue点tab不刷新页面_如何使tab页切换,页面不刷新
  14. CodeForces 1253C
  15. 猿人学试题(非常简单js混淆、雪碧图、样式干扰 css加密、js混淆源码乱码、js混淆动态cookie、访问逻辑)
  16. 微信开发者工具,调试公众号网页,控制台不显示,解决方案
  17. Delphi官方下载地址
  18. 无锡:车联网先导区“排头兵”,编织的自动驾驶产业雄心!
  19. 迅雷高速下载免安装 Kali Linux
  20. 计算机职称证书退休工资,职称就像是一座大山,相同教龄不同职称的教师退休工资相差多少?...

热门文章

  1. java对接自动充电桩_一种便于自动对接的充电接头的制作方法
  2. C++程序设计(检测纽扣是否存在缺陷)
  3. 怎么用显卡计算_显卡性能的软件 3dmark怎么用
  4. 【每日一题】027 奇妙的数字
  5. win10将硬盘作为存储池删除读不到盘符_东芝的传承,我来延续:铠侠TC10 SATA固态硬盘上手评测...
  6. 荷月区块链供应链金融平台系统入选2020区块链技术创新成果
  7. vue读取文件夹下面的文件名称
  8. 7. 调度问题schedule
  9. 阿里数据分析试题解析
  10. (附源码)springboot幼儿园书刊信息管理系统 毕业设计141858