为什么从“活动监视器”和“仪器”中查看的内存消耗如此不同。
我的应用程序是一个音乐播放器,它通过 AV Foundation 连续播放来自互联网的 MP3。它存在内存消耗问题。
当我使用分配或泄漏工具查找原因时,活动监视器报告内存消耗为 50MB 左右。 当我使用“产品”->“运行”运行应用程序时,活动监视器报告最初的内存消耗为 20MB,并且每秒增加 100kB。为什么他们如此不同?
此外,分配或泄漏工具都有“分配”行。分配中的右侧栏逐渐变成红色。 Leaks 中的右侧栏始终为蓝色。 “分配”行在这两种工具中的工作方式不同吗?我使用 Xcode 4.1。
My app is a music player, it plays MP3's continuously from internet with AV Foundation. It has memory consumption issues.
When I look for the reason with Allocations or Leaks instruments, the Activity Monitor reports memory consumptions of 50MB or so.
When I run the app with Product->Run, the Activity Monitor reports memory consumptions of 20MB initially, and it increases 100kB per second. Why are they so different?
Further more, the Allocations or Leaks instruments all have the 'Allocations' row. The right side bars in Allocations gradually turn into red. The right side bars in Leaks are always blue. The 'Allocations' row works differently in these two instruments? I use Xcode 4.1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了回答上一段中的问题,分配工具针对分配和泄漏模板进行了不同的配置。在分配模板中,仪器跟踪所有内存分配。在泄漏模板中,工具仅跟踪活动分配。直方图(右侧的彩色条)反映了活跃分配与总分配的比率,蓝色表示高比率,红色表示低比率。由于 Leaks 工具仅跟踪活动分配,因此活动分配等于总分配,从而为您提供蓝色直方图。单击分配工具旁边的信息按钮以配置其记录的内容。
如果您想查看应用程序使用了多少内存,请查看分配工具中“所有分配”类别的“实时字节”列。另外,请看一下以下问题:
Xcode Instruments 输出解释适用于 iPad 应用程序
To answer the question in the last paragraph, the Allocations instrument is configured differently for the Allocations and Leaks templates. In the Allocations template, the instrument tracks all memory allocations. In the Leaks template the instrument tracks only active allocations. The histogram (the colored bar on the right side) reflects the ratio of active to total allocations, with blue indicating a high ratio and red indicating a low ratio. Because the Leaks instrument tracks only active allocations, the active allocations equal the total allocations, giving you a blue histogram. Click the Info button next to the Allocations instrument to configure what it records.
If you want to see how much memory your application is using, look at the Live Bytes column for the All Allocations category in the Allocations instrument. Also, take a look at the following question:
Xcode Instruments output interpretation for iPad app