问题描述
我正在研究我的第一个ARC&核心数据项目,基于Xcode的(通用)主 - 细节模板。
我注意到Xcode5在Debug Navigator中有一个内存显示,但在使用它时,发现它的图形与运行Leaks& Allocations跟踪时Instruments中显示的mem使用几乎没有相似之处。
我已经使用模拟器完成了仪器跟踪(模拟了iPhone和iPad - 如果细节View的'卸载',后者有所不同)和iPad2&一个iPodTouch。结果大致相同:
I'm working on my first ARC & Core Data project, basing this stage on Xcode's (Universal) Master-Detail template.I note that Xcode5 has a memory display in the Debug Navigator but when using it find its graph bears few similarities with mem usage displayed in Instruments when running a Leaks&Allocations trace.I've done the Instruments tracing with the Simulator (simulating both iPhone & iPad - in case the 'unloading' of the detail View with the latter makes a difference) and on an iPad2 & an iPodTouch. The results are broadly the same:
- A代-------- 1.13 MB
- B代-------- 397.70 KB
- C代-------- 76.96 KB
- D代-------- 11.70 KB
- E代 - ------ 1.56 KB
- F代-------- 3.48 KB
- Generation A--------1.13 MB
- Generation B--------397.70 KB
- Generation C--------76.96 KB
- Generation D--------11.70 KB
- Generation E--------1.56 KB
- Generation F--------3.48 KB
总体增长率为c30%
其中A代显示主表加载的增长,并且每个连续在详细信息视图访问并且与交互后生成增长(需要获取NSManagedObjects 和创建NSObjects ,分别)。
与其他设备的增长趋势大致相似(A代增长为iPad sim:1.42; iPad2:1.57; iPodTouch:0.94但同样拖尾)。
where Generation A shows the growth to the loading of the Master table, and each successive Generation the growth after the Detail view has been visited and interacted with (entailing the fetching of NSManagedObjects and the creation of NSObjects, respectively).The growth trend with the other devices was broadly similar (with the Generation A growth being iPad sim:1.42; iPad2:1.57; iPodTouch:0.94 but tailing off similarly).
然而,根据Debug Navigator,每个点的 总 用法出现在:
According to the Debug Navigator, however, the total usage at each point comes out at:
- A代-------- 4.2 MB
- B代-------- 6.9 MB - 增长2.7
- C代-------- 7.1 MB - 增长0.2
- D代-------- 7.8 MB - 增长0.7
- E代-------- 8.0 MB --growth 0.2
- F代-------- 8.4 MB - 增长0.4
整体增长率为100%!
- Generation A--------4.2 MB
- Generation B--------6.9 MB--growth 2.7
- Generation C--------7.1 MB--growth 0.2
- Generation D--------7.8 MB--growth 0.7
- Generation E--------8.0 MB--growth 0.2
- Generation F--------8.4 MB--growth 0.4
an overall growth of 100%!
参考其他类似的问题,我没有启用Zombies。
让其他人看到这样的差异吗?我是否正确倾向于相信仪器而不是Debug Navigator的总结数字?
Referring to other similar questions, I don't have Zombies enabled.Have others seen such discrepancies? Am I right in being inclined to trust Instruments over the Debug Navigator's summary figure?
PS。运行真实设备时(在iOS5版本上),Debug Navigator的摘要图似乎不可用。这是正常的吗?
PS. Debug Navigator's summary figure doesn't seem to be available when running the real devices (both on versions of iOS5). Is this normal?
推荐答案
这对你来说可能不是一个很好的答案,但我对这个问题的理由是我的理由。完成。
This may not be a very good answer for you, but it is my justification for this issue with the research that I have done.
调试导航器显示与活动监视器工具相同的内容。它没有显示您的应用程序当前分配的内存,它显示操作系统允许您的应用程序的当前内存。
The debug navigator shows the same things as the "Activity Monitor" instrument. It is not showing current allocated memory by your app, it's showing current memory allowed to your app by the OS.
假设我创建一个for循环来创建大量对象记忆,但后来我删除了一半,因为它们不符合我的搜索条件(编码不好,我知道,但假设在这里)。操作系统将从您的应用程序获取完整内存的请求以创建所有对象,但在循环后检查您在仪器中的分配时,它仅显示已保存的对象,因为垃圾收集取出了已删除的对象。操作系统可能会或可能不知道垃圾收集事件,但它不会占用它只是让你离开的内存。我不确定从您的应用程序提供/获取可用内存的开销,但我确信他们会考虑到这一点。我注意到,如果我单独留下我的应用程序,操作系统会占用一些我没有使用的内存。
Say I create a for loop to create lots of objects in memory, but then I delete half of them because they don't fit my search criteria (bad coding, I know, but hypothetically here). The OS would get a request from your app for the full memory to create all of the objects, but after the loop when you check your allocations in instruments it shows only the saved objects because garbage collection took out the deleted ones. The OS may or may not know about the garbage collection events, but it doesn't take the memory that it just gave you away. I'm not sure of the overhead of giving/taking available memory from your app, but I'm sure they take that into account. I've noticed that if I leave my app alone long enough the OS takes some of the memory I'm not using back.
只需将调试内存信息视为您的应用程序的全部内存由操作系统分配。您可能没有使用所有这些,但操作系统无论如何都给了您(出于某种原因)。此数字将根据您应用的请求/使用情况而增加。它会因内存压力警告或操作系统认为可以安全地从您恢复内存的不活动而减少。它可能永远不会匹配仪器分配的内存信息,因为在应用程序中总是使用瞬态内存,甚至需要在短时间内分配到某些地方。
Just think of the debugging memory information as your app's full memory allotted by the OS. You may not be using all of it, but the OS gave it to you anyway (for one reason or another). This number will increase based on your app's requests/use. It will decrease due to Memory Pressure warnings or inactivity that the OS thinks it can safely recover the memory from you. It will likely never match the Instruments allocated memory information because there is always transient memory used in applications that needs to be allocated somewhere even for a short time.
再次,这是我的结论基于我何时想知道你是一回事。希望它有所帮助。
Again, this is my conclusion based on when I was wondering the same thing you are. Hope it helps a little.
这篇关于XCode 5 Debug Navigator Memory不同意Instruments的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!