iOS内存分配 - 应用程序可以使用多少内存? [英] iOS memory allocation - how much memory can be used in an application?

查看:309
本文介绍了iOS内存分配 - 应用程序可以使用多少内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOs是否在内存管理中使用非连续或连续的分配?假设用户分配的内容超过128 MB,应用程序是否会被关闭?或者内存将由iOS管理,就像用户分配内存并在Deallocate方法中错过deallocate一样?是否可以使用明确定义的数据结构分配在应用程序中使用超过120 MB?

Does iOs use non-contiguous or contiguous allocation in memory management? suppose if user allocates more than 128 MB, Will the App be closed? or Memory will be managed by iOS as if user allocates memory and misses deallocate in Deallocate method? is it possible to use more than 120 MB in application using well-defined data structure allocation?

推荐答案

来自单独内存分配的块是没有连续分配(单独调用alloc,malloc,new等)。否则它们是连续分配的(从对malloc的同一个调用,例如new float [30])。根据Apple的说法,当您使用超过20mb的RAM时,您的应用程序可能会因内存使用而被关闭。然而,在实践中,你可以得到... ...

Blocks from separate memory allocations are not allocated contiguously (separate calls to alloc, malloc, new, etc.). Otherwise they are allocated contiguously(from the same call to malloc, ex. new float[30]). According to Apple your app risks being shut down for memory usage when you use more than 20mb of ram. In practice however, you can get to about...


  • iPad 2上的260 MB RAM(感谢RobCroll)

  • 总容量为512 Mb的设备上有170-180MB内存(iPhone 4,iPod touch 4g)

  • 在256 MB的设备上使用40-80MB内存ram(iPad,iPhone 3gs,iPod touch 3g)

  • 25 MB的设备只有128MB的RAM(IPhone 3g,iPhone 2g,iPod touch 1g-2g)

  • 260 MB of ram on iPad 2 (Thanks RobCroll)
  • 170-180MB of ram on devices with 512 Mb of ram total (iPhone 4, iPod touch 4g)
  • 40-80MB of ram on devices that have 256 MB of ram (iPad, iPhone 3gs, iPod touch 3g)
  • 25 MB on device with only 128MB of ram (IPhone 3g, iPhone 2g, iPod touch 1g-2g)

如果您真的需要移动应用程序的那么多内存,您应该将数据保存到临时文件并对其进行处理。一种简单的方法是使用内存映射文件。

If you really "need" that much ram for a mobile application, you should really save the data to a temp file and do your processing on that. An easy way to do that is by using memory mapped files.

这篇关于iOS内存分配 - 应用程序可以使用多少内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆