什么是iOS内存占用的正确统计数据。直播字节?真实记忆?其他? [英] What's the right statistic for iOS Memory footprint. Live Bytes? Real Memory? Other?

查看:379
本文介绍了什么是iOS内存占用的正确统计数据。直播字节?真实记忆?其他?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这一点上确实很困惑。

I'm definitely confused on this point.

我有一个iPad应用程序,在对象分配工具中显示Live Bytes使用量为6-12mb。如果我拉起内存监视器或活动监视器,真实内存列在经过一些严重使用后一直攀升到80-90mb左右。

I have an iPad application that shows 'Live Bytes' usage of 6-12mb in the object allocation instrument. If I pull up the memory monitor or activity monitor, the 'Real Memory' Column consistently climbs to around 80-90mb after some serious usage.

所以我是否正常内存占用量还是很高?

So do I have a normal memory footprint or a high one?

此答案和< a href =https://stackoverflow.com/a/8797272/287403>这个答案声称您应该观看实时内存,因为真实内存列显示已发布的内存块,但是OS还没有收回它。

This answer and this answer claim you should watch 'Live Bytes' as the 'Real Memory' column shows memory blocks that have been released, but the OS hasn't yet reclaimed it.

另一方面,这个答案声称您需要注意该内存监视器,因为Live Bytes不包含界面元素等内容。

On the other hand, this answer claims you need to pay attention to that memory monitor, as the 'Live Bytes' doesn't include things like interface elements.

什么是处理iOS内存占用!?:)

推荐答案

这些只是衡量内存使用的两个不同指标。哪一个是正确的取决于你想要回答的问题。

Those are simply two different metrics for measuring memory use. Which one is the "right" one depends on what question you're trying to answer.

简而言之,活字节和真实记忆之间的区别是当前用于您的应用创建的内容的内存量与当前归因于您的应用的物理内存总量之间的差异。这些不同的原因至少有两个:

In a nutshell, the difference between "live bytes" and "real memory" is the difference between the amount of memory currently used for stuff that your app has created and the total amount of physical memory currently attributed to your app. There are at least two reasons that those are different:


  • 代码:您的应用代码必须当然,加载到内存中,虚拟内存系统肯定会将其归因于您的应用,即使它不是您的应用分配的内存。

  • code: Your app's code has to be loaded into memory, of course, and the virtual memory system surely attributes that to your app even though it's not memory that your app allocated.

内存池:大多数分配器通过维护一个或多个内存池来工作,它们可以从中创建单个对象或已分配内存块的片段。大多数 malloc 的实现都是这样的,我希望对象分配器也能这样做。当一个对象被释放时,这些池不会自动向下调整大小 - 内存只是在池中标记为空闲,但整个池仍然会归因于您的应用程序。

memory pools: Most allocators work by maintaining one or more pools of memory from which they can carve off pieces for individual objects or allocated memory blocks. Most implementations of malloc work that way, and I expect that the object allocator does too. These pools aren't automatically resized downward when an object is deallocated -- the memory is just marked 'free' in the pool, but the whole pool will still be attributed to your app.

可能有其他方式将内存归因于您的应用,而不是由您的代码直接分配。

There may be other ways that memory is attributed to your app without being directly allocated by your code, too.

那么,你想了解你的应用程序是什么?如果你想弄清楚你的应用程序因内存不足而崩溃的原因,请查看实时字节(看看你的应用现在使用的是什么)和真实内存(看看VM系统说你的内存有多少应用正在使用)。如果您正在尝试提高应用程序的内存性能,查看实时字节或活动对象更有可能有所帮助,因为这是您可以执行某些操作的内存。

So, what are you trying to learn about your application? If you're trying to figure out why your app crashed due to low memory, look at both "live bytes" (to see what your app is using now) and "real memory" (to see how much memory the VM system says your app is using). If you're trying to improve your app's memory performance, looking at "live bytes" or "live objects" is more likely to help, since that's the memory that you can do something about.

这篇关于什么是iOS内存占用的正确统计数据。直播字节?真实记忆?其他?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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