ios莫名其妙闪退的解决方法

2024-05-28 01:58

本文主要是介绍ios莫名其妙闪退的解决方法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

使用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"

请看下图:

QQ图片20130906181222

我们在上面看到了-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莫名其妙闪退的解决方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1009227

相关文章

解决java.lang.NullPointerException问题(空指针异常)

《解决java.lang.NullPointerException问题(空指针异常)》本文详细介绍了Java中的NullPointerException异常及其常见原因,包括对象引用为null、数组元... 目录Java.lang.NullPointerException(空指针异常)NullPointer

Android开发中gradle下载缓慢的问题级解决方法

《Android开发中gradle下载缓慢的问题级解决方法》本文介绍了解决Android开发中Gradle下载缓慢问题的几种方法,本文给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录一、网络环境优化二、Gradle版本与配置优化三、其他优化措施针对android开发中Gradle下载缓慢的问

python 3.8 的anaconda下载方法

《python3.8的anaconda下载方法》本文详细介绍了如何下载和安装带有Python3.8的Anaconda发行版,包括Anaconda简介、下载步骤、安装指南以及验证安装结果,此外,还介... 目录python3.8 版本的 Anaconda 下载与安装指南一、Anaconda 简介二、下载 An

python安装whl包并解决依赖关系的实现

《python安装whl包并解决依赖关系的实现》本文主要介绍了python安装whl包并解决依赖关系的实现,文中通过图文示例介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面... 目录一、什么是whl文件?二、我们为什么需要使用whl文件来安装python库?三、我们应该去哪儿下

MySQL安装时initializing database失败的问题解决

《MySQL安装时initializingdatabase失败的问题解决》本文主要介绍了MySQL安装时initializingdatabase失败的问题解决,文中通过图文介绍的非常详细,对大家的学... 目录问题页面:解决方法:问题页面:解决方法:1.勾选红框中的选项:2.将下图红框中全部改为英

Java中将异步调用转为同步的五种实现方法

《Java中将异步调用转为同步的五种实现方法》本文介绍了将异步调用转为同步阻塞模式的五种方法:wait/notify、ReentrantLock+Condition、Future、CountDownL... 目录异步与同步的核心区别方法一:使用wait/notify + synchronized代码示例关键

Python使用Pandas对比两列数据取最大值的五种方法

《Python使用Pandas对比两列数据取最大值的五种方法》本文主要介绍使用Pandas对比两列数据取最大值的五种方法,包括使用max方法、apply方法结合lambda函数、函数、clip方法、w... 目录引言一、使用max方法二、使用apply方法结合lambda函数三、使用np.maximum函数

Qt 中集成mqtt协议的使用方法

《Qt中集成mqtt协议的使用方法》文章介绍了如何在工程中引入qmqtt库,并通过声明一个单例类来暴露订阅到的主题数据,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友一起看看吧... 目录一,引入qmqtt 库二,使用一,引入qmqtt 库我是将整个头文件/源文件都添加到了工程中进行编译,这样 跨平台

Nginx设置连接超时并进行测试的方法步骤

《Nginx设置连接超时并进行测试的方法步骤》在高并发场景下,如果客户端与服务器的连接长时间未响应,会占用大量的系统资源,影响其他正常请求的处理效率,为了解决这个问题,可以通过设置Nginx的连接... 目录设置连接超时目的操作步骤测试连接超时测试方法:总结:设置连接超时目的设置客户端与服务器之间的连接

Java判断多个时间段是否重合的方法小结

《Java判断多个时间段是否重合的方法小结》这篇文章主要为大家详细介绍了Java中判断多个时间段是否重合的方法,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录判断多个时间段是否有间隔判断时间段集合是否与某时间段重合判断多个时间段是否有间隔实体类内容public class D