关于内存优化,人云亦云 各有己见。本文将通过设置Strpping Level ,减少内存使用。

先看三幅图:

1、没做任何优化,默认选项

2、设置Stripping level 为 Use micro mscorlib; 设置 script call Optimization为Fast but no exceptions

因为本demo用到jsonFX json解析器,牵扯到system.dll 里面的东西,所以程序直接崩掉。(Don't use anything that lives in System.dll or System.Xml.dll in your code. Those two are not compatible with micro mscorlib.)

3、解决了以上bug,优化后的效果:   内存基本减少了8.5MB 左右

如何解决第二部的残留问题呢:官方给了这么一个说法

How to Deal with Stripping when Using Reflection

Stripping heavily depends on static code analysis and sometimes it fails to do the job right, especially when dynamic features (like reflection) are used. In such cases some hinting what classes shouldn't be touched is needed. Unity iOS supports per project custom stripping black list. The process is simple:

1. Create link.xml file and place it directly into Assets (project root) folder.

2. link.xml sample structure is as follows:

<linker>
       <assembly fullname="System.Web.Services">
               <type fullname="System.Web.Services.Protocols.SoapTypeStubInfo" preserve="all"/>
               <type fullname="System.Web.Services.Configuration.WebServicesConfigurationSectionHandler" preserve="all"/>
       </assembly>
       <assembly fullname="System">
               <type fullname="System.Net.Configuration.WebRequestModuleHandler" preserve="all"/>
               <type fullname="System.Net.HttpRequestCreator" preserve="all"/>
               <type fullname="System.Net.FileWebRequestCreator" preserve="all"/>
       </assembly>
</linker>

结合本例:需要如下link.xml文件

<linker>
       <assembly fullname="System">
            <type fullname="System.ComponentModel.TypeConverter" preserve="all"/>
            <type fullname="System.ComponentModel.ArrayConverter" preserve="all"/>
            <type fullname="System.ComponentModel.BaseNumberConverter" preserve="all"/>
            <type fullname="System.ComponentModel.BooleanConverter" preserve="all"/>
            <type fullname="System.ComponentModel.ByteConverter" preserve="all"/>
            <type fullname="System.ComponentModel.CharConverter" preserve="all"/>
            <type fullname="System.ComponentModel.CollectionConverter" preserve="all"/>
            <type fullname="System.ComponentModel.ComponentConverter" preserve="all"/>
            <type fullname="System.ComponentModel.CultureInfoConverter" preserve="all"/>
            <type fullname="System.ComponentModel.DateTimeConverter" preserve="all"/>
            <type fullname="System.ComponentModel.DecimalConverter" preserve="all"/>
            <type fullname="System.ComponentModel.DoubleConverter" preserve="all"/>
            <type fullname="System.ComponentModel.EnumConverter" preserve="all"/>
            <type fullname="System.ComponentModel.ExpandableObjectConverter" preserve="all"/>
            <type fullname="System.ComponentModel.Int16Converter" preserve="all"/>
            <type fullname="System.ComponentModel.Int32Converter" preserve="all"/>
            <type fullname="System.ComponentModel.Int64Converter" preserve="all"/>
            <type fullname="System.ComponentModel.NullableConverter" preserve="all"/>
            <type fullname="System.ComponentModel.SByteConverter" preserve="all"/>
            <type fullname="System.ComponentModel.SingleConverter" preserve="all"/>
            <type fullname="System.ComponentModel.StringConverter" preserve="all"/>
            <type fullname="System.ComponentModel.TimeSpanConverter" preserve="all"/>
            <type fullname="System.ComponentModel.UInt16Converter" preserve="all"/>
            <type fullname="System.ComponentModel.UInt32Converter" preserve="all"/>
            <type fullname="System.ComponentModel.UInt64Converter" preserve="all"/>
       </assembly>
</linker>

第二步的错误得出 JsonFX需要依赖System.dll中的类型转化函数,所以通过以上link文件 保留system.dll中的类型转换函数。

另附:反射的link如下:

<linker>
            <assembly fullname="mscorlib">
                   <type fullname="System.Reflection"preserve="all"/>
                   <type fullname="System.Security.Cryptography"preserve="all"/>
           </assembly>
</linker>

参考资料:http://www.rbcafe.com/Softwares/Unity/Documentation/Manual/iphone-playerSizeOptimization.html

[原]unity3d ios平台内存优化(一)的更多相关文章

  1. [转]ios平台内存常见问题

    本文转自CocoaChina,说的满详细的: 链接地址:http://www.cocoachina.com/bbs/read.php?tid=94017&keyword=%C4%DA%B4%E ...

  2. Unity3D移动端内存优化(NGUI方面)

     Unity3D引擎技术交流QQ群:[21568554] 做3d移动端内存一直是人们头疼的问题,载入的资源释放了,还有其它的须要释放.比方ngui释放,事实上主要是NGUI的Texture和Spr ...

  3. Unity3D 的大场景内存优化

    我们公司的一个 MMORPG 项目最近在内存方面碰到了红线,昨天开会讨论了一下.我提出了一个改进方案,写篇 blog 记录一下. 问题是这样的.在当下的手机及平板硬件设备条件下,操作系统留给应用的可用 ...

  4. iOS App内存优化之 解决UIImagePickerController的图片对象占用RAM过高问题

    这个坑会在特定的情况下特别明显: 类似朋友圈的添加多张本地选择\拍照 的图片 并在界面上做一个预览功能 由于没有特别的相机\相册需求,则直接使用系统自带的UIImagePickerController ...

  5. [原]unity3D 移动平台崩溃信息收集

    http://m.blog.csdn.net/blog/catandrat111/8534287http://m.blog.csdn.net/blog/catandrat111/8534287

  6. iOS基础 - 内存分析

    一.内存的重要性 程序是否可用的最根本的制约因素. 十分影响用户体验. 程序的crash有很多情况都是内存的原因. 二.iOS平台内存警告机制 iOS系统不支持虚拟内存,一旦出现内存不足的情况,iOS ...

  7. Unity3D 游戏开发之内存优化

    项目的性能优化主要围绕CPU.GPU和内存三大方面进行. 无论是游戏还是VR应用,内存管理都是其研发阶段的重中之重. 然而,在我们测评过的大量项目中,90%以上的项目都存在不同程度的内存使用问题.就目 ...

  8. 转 iOS和android游戏纹理优化和内存优化(cocos2d-x)

    iOS和android游戏纹理优化和内存优化(cocos2d-x) (未完成) 1.2d游戏最占内存的无疑是图片资源. 2.cocos2d-x不同平台读取纹理的机制不同.ios下面使用CGImage, ...

  9. iOS性能优化-内存优化

    https://blog.csdn.net/a184251289/article/details/82589128 2018年09月10日 14:25:31 xingshao1990 阅读数:328 ...

随机推荐

  1. c# 反射取其他项目的资源文件

    反射获取其他项目里面的资源文件. dll或exe里面 try { System.Reflection.Assembly dll = System.Reflection.Assembly.LoadFil ...

  2. 阿里云扩容数据盘_Linux

    扩容数据盘_Linux 更新时间:2018-10-11 15:18:46 · 编辑者 编辑 · ★ 我的收藏 新手学堂 学习路径 本页目录 前提条件 注意事项 步骤 1. 在控制台上扩容数据盘的磁盘空 ...

  3. 微信小程序——video使用总结

    关于小程序video的一些基本使用方法,可点击这里稍作了解. 需求: 1.默认显示封面: 2.一个视频播放的时候,其他视频停止播放,并显示封面. 解决问题思路: 1.通过wx:if判断当前视频是否是播 ...

  4. Qt学习 之 QWebView

    WebKit 是一个开源的浏览器引擎,目前 Safari,Chrome 等浏览器均使用了 WebKit 作为核心.Qt 从 4.5 版本开始,集成了 WebKit 作为 Qt 的平台组件,用户可以像使 ...

  5. L1&L2 Regularization

    正则化方法:防止过拟合,提高泛化能力 在训练数据不够多时,或者overtraining时,常常会导致overfitting(过拟合).其直观的表现如下图所示,随着训练过程的进行,模型复杂度增加,在tr ...

  6. c数据结构第一个公式写程序计算给定多项式在给定点x处的值

    假设x=2,那么a的数组有几个, 那n就是根据索引来的 假设数组[, , , , ] n就是0, 1, 2,,3, 4 f = + ( + ( + ( + ()))) f = + ( + ( + ( ...

  7. (笔记)Mysql命令drop table:删除数据表

    drop table命令用于删除数据表. drop table命令格式:drop table <表名>; 例如,删除表名为 MyClass 的表:    mysql> drop ta ...

  8. matlab中的常用的函数——在稀疏表示中学习到的

    1, 矩阵的逆: inv()函数: 2. 矩阵的伪逆: pinv()函数: 3. 矩阵的克罗内克尔积: kron()函数: 4. 得到一个dct变换的字典: dctmtx()函数, 它可以得到一个 n ...

  9. 第三百三十三节,web爬虫讲解2—Scrapy框架爬虫—Scrapy模拟浏览器登录—获取Scrapy框架Cookies

    第三百三十三节,web爬虫讲解2—Scrapy框架爬虫—Scrapy模拟浏览器登录 模拟浏览器登录 start_requests()方法,可以返回一个请求给爬虫的起始网站,这个返回的请求相当于star ...

  10. elasticsearch系列三:索引详解(分词器、文档管理、路由详解(集群))

    一.分词器 1. 认识分词器  1.1 Analyzer   分析器 在ES中一个Analyzer 由下面三种组件组合而成: character filter :字符过滤器,对文本进行字符过滤处理,如 ...