您如何看待 XCode Instruments 中负责内存分配的具体方法?
我被要求尝试减少我所获得的应用程序代码中的内存使用量。该应用程序在模拟器中运行良好,但在设备上它被终止或其他什么情况,在调试时它进入“暂停”状态并且应用程序在设备上关闭。
在运行仪器时,我发现了泄漏,并修复了它们,但是正在进行大量分配。启动后几秒钟内,仪器分配跟踪显示“Malloc 16 字节”为 1,021 KB。这本质上是无用的信息,我需要查看内存分配的位置,但我似乎找不到任何有用的信息。我所能得到的更深入的检查是“dyld”、“libsystem_c.dylib”、“libCGFreetype.A.dylib”等分配了很多,但负责任的调用者从来都不是应用程序源中可识别的方法。
我如何才能看到哪些方法导致了最多的分配?我需要减少这种用法!谢谢
I've been asked to try and reduce memory usage in an app's code I have been given. The app runs fine in the simulator but on the device it is terminated or something, when debugging it enters a 'Paused' state and the app closes on the device.
When running instruments I discovered leaks, fixed them, however there is a large amount of allocation going on. Within a few seconds of launch the instruments allocation trace shows 1,021 KB for 'Malloc 16 Bytes'. This is essentially useless information as is, I need to see where the memory is being allocated but I can't seem to find anything useful. All i can get for a deeper inspection is that 'dyld', 'libsystem_c.dylib', 'libCGFreetype.A.dylib' etc are allocating a lot, but the responsible caller is never a recognizable method from the app source.
How can I see what methods are causing the most allocations here? I need to get this usage down! Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
打开扩展详细视图将显示内存分配的调用堆栈。选择查看>扩展详细信息打开扩展详细信息视图。
切换到调用树视图将帮助您找到在代码中分配内存的位置。使用跳转栏切换到调用树视图。
Opening the extended detail view will show the call stack for memory allocations. Choose View > Extended Detail to open the extended detail view.
Switching to the call tree view will help you find where you are allocating memory in your code. Use the jump bar to switch to the call tree view.
1MB 没什么大不了的。如果不使用 1MB,就无法提供完整视图。
WWDC 2010 (http://developer.apple.com/videos/wwdc/2010/) 中有一个很好的视频,其中介绍了如何使用仪器来分析内存使用情况。标题是使用仪器进行高级内存分析。可能有 2011 年的更新视频。
1MB is no big deal. You can't do much in terms of throwing up a full view without using 1MB.
There's a good video from WWDC 2010 (http://developer.apple.com/videos/wwdc/2010/) that covers using instruments to analyze memory use. Title is Advanced Memory Analysis with Instruments. There may be an updated video from 2011.