调试期间 XCode 5 中的内存图/图表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19394107/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Memory graph / chart in XCode 5 during Debug
提问by Ashok
What does "Memory" usage chart/graph exactly represents in XCode 5 Debug navigator window?
“内存”使用图表/图形在 XCode 5 调试导航器窗口中究竟代表什么?
I have an iOS app project with ARC disabled and no-storyboard/xib (i.e. old style). All memory management done manually using retain/release/autorelease.
我有一个禁用 ARC 且没有故事板/xib(即旧样式)的 iOS 应用程序项目。使用保留/释放/自动释放手动完成所有内存管理。
When I debug the project in XCode 5, the memory pie-chart / graph show gradually increasing memory usage as the app runs, exceeds 1 GB memory footprints within half hour.
当我在 XCode 5 中调试项目时,内存饼图/图形显示随着应用程序运行逐渐增加内存使用量,在半小时内超过 1 GB 内存占用。
Roughly, it keeps increasing by 0.1 to 0.3 MB per 2 to 3 second with very rare memory dips/decrease (of magnitude < 0.1 MB per 30 seconds).
粗略地说,它每 2 到 3 秒不断增加 0.1 到 0.3 MB,内存下降/减少非常罕见(每 30 秒幅度 < 0.1 MB)。
Is this a concern (memory leak) with respect to memory management? I did memory analysis (using Allocations/Memory Leak through Instruments on XCode 4.6) but didn't find any leaks.
这是内存管理方面的问题(内存泄漏)吗?我进行了内存分析(在 XCode 4.6 上通过仪器使用分配/内存泄漏),但没有发现任何泄漏。
回答by Ashok
Found answer myself. Unfortunately I had NSZombieEnabled (Zombie object) for debug mode - see below - (menu Product> Scheme> Edit Scheme)
自己找到了答案。不幸的是,我在调试模式下使用了 NSZombieEnabled(僵尸对象)——见下文——(菜单Product> Scheme> Edit Scheme)
Typically NSZombieEnabled tool keeps even the released objects in memory to help developer find over released objects. Refer this link - What is NSZombie?
通常,NSZombieEnabled 工具会将已释放的对象保存在内存中,以帮助开发人员查找已释放的对象。请参阅此链接 -什么是 NSZombie?
After I unchecked"Enable Zombie Objects" option, the memory usage stabilized to about 10 mb (not always increasing) even after half hour app usage - see below -
在我取消选中“启用僵尸对象”选项后,即使在半小时的应用程序使用后,内存使用量也稳定在大约 10 mb(并不总是增加) - 见下文 -
BOTTOM LINE- Ensure to clear "Enable Zombie Objects" when you want to analyze memory usage.
底线-当您要分析内存使用情况时,请确保清除“启用僵尸对象”。
回答by James Campbell
It simply measures the memory your app uses. So if it is increasing it must be a memory leak.
它只是衡量您的应用程序使用的内存。因此,如果它正在增加,则必须是内存泄漏。
When using the leak analysis tools, I would use it as a guideline. It may help you find leaks but with all automated tools it may not find it all. As certain pieces of code (Especially the more dynamic pieces) may be hard to predict what they do memory wise for an automated tool.
使用泄漏分析工具时,我会将其用作指南。它可能会帮助您找到泄漏,但使用所有自动化工具可能无法全部找到。由于某些代码片段(尤其是更动态的片段)可能很难预测它们在内存方面为自动化工具做什么。
回答by lupinglade
I am seeing an issue where memory (heap) grows indefinitely on heavy processing but when running the exact same binary without Xcode; memory usage is fine. Remember to test outside of Xcode -- no idea what the cause is. NSZombies and all other debug options are off.
我看到一个问题,内存(堆)在繁重的处理中无限增长,但在没有 Xcode 的情况下运行完全相同的二进制文件时;内存使用没问题。请记住在 Xcode 之外进行测试——不知道原因是什么。NSZombies 和所有其他调试选项都关闭了。