iOS开发-面试总结(十六)

内存问题

一:手机内存容量

  • 最新苹果手机iPhone6s(plus)现在有2GB运行内存。
  • iPhone5、iPhone5s和iPhone6(plus)运行内存为1GB。
  • iPhone4和iPhone4s运行内存为512MB。

二:App运行内存

  • 建议不要超过 10M. 如果用户 只运行一个程序 内存是用可以到 30M 左右. 
  • 不过这概率 几乎不可能. 
  • 一般 超过 10M 就会 memory warning L1 系统会 kill 一些不用的 view 


外国大牛的测试结果
So it turns out if you allocate (and use!) around 46-50 MB in your iPhone application it will just get terminated.

如何保持内存(运行)占用不要太高?

    • 1. tableviewCell中的icon图片要用剪裁过的, 不要把那些1M左右的图片直接从web端传输过来
    • 2. 一些比较深,或者循环比较多的代码block中, 尽量在外围套一层autorelease pool, 执行完毕后直接[pool drain]
    • 3. tableview cell一定要reuse, 其他类似的view也要reuse.
原文地址:https://www.cnblogs.com/stronger-ios-lcx/p/5634968.html