[英]What amount of memory should I target for my iOS app?
I am currently showing that my app is using a maximum of 200MB when it is running. 我目前正在显示我的应用程序在运行时使用的最大内存为200MB。 Is there a way to tell if this is going to trigger a low memory warning? 有没有办法判断这是否会触发内存不足警告? So far I have not had any issues with the simulator or actuall devices. 到目前为止,模拟器或实际设备还没有任何问题。
We must avoid spiking the memory. 我们必须避免增加记忆力。 For example loading images from disk or cache in loop. 例如,从磁盘或缓存中循环加载图像。 This will create a memory spike and it is at this point iOS starts to throw low memory warnings. 这将导致内存峰值,并且此时iOS开始引发内存不足警告。 The exact amount of memory is not specified by Apple. Apple未指定确切的内存量。 In many applications I have observed that as the memory grows gradually iOS is comfortable and app works properly. 在许多应用程序中,我观察到随着内存的逐渐增长,iOS变得很舒适,并且应用程序可以正常运行。 But if memory spike occurs low memory warning is thrown. 但是,如果发生内存高峰,则会引发内存不足警告。
Apps can use 200 MB of memory these days easily, how ever it is important to simulate and handle low memory warnings in order to be on the safe side. 这些天,应用程序可以轻松使用200 MB内存,因此,为了安全起见,模拟和处理内存不足警告非常重要。
If you want to trigger low memory warning using simulator, there is a option of doing so in the Menu->Debug of Simulator (Cmd+Shift+M). 如果要使用模拟器触发内存不足警告,可以在菜单->模拟器调试(Cmd + Shift + M)中进行选择。 In device you may load some big images in a for loop. 在设备中,您可能会在for循环中加载一些大图像。 You may also call a private method. 您也可以调用私有方法。 [[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)]; [[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)]; Just be sure that this code does not go to production as Apple will reject the binary as private method is being used. 只需确保此代码不会投入生产,因为当使用私有方法时,Apple将拒绝该二进制文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.