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

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

问题描述

iO 在内存管理中使用非连续分配还是连续分配?假设如果用户分配超过 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 的内存时,您的应用程序可能会因内存使用而被关闭.然而,在实践中,你可以得到大约...

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 内存(感谢 RobCroll)
  • 170-180MB 内存,总内存为 512 Mb 的设备(iPhone 4、iPod touch 4g)
  • 在具有 256 MB 内存的设备(iPad、iPhone 3gs、iPod touch 3g)上使用 40-80MB 内存
  • 只有 128MB 内存的设备上 25 MB(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天全站免登陆