xcode 我如何测试 iphone 应用程序的内存泄漏?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4794170/
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
How can i test iphone application for memory leaks?
提问by Andrew
What are the methods/tools i can use to check if in my application for iphone there are no memory leaks? Or how to find and fix them?
我可以使用哪些方法/工具来检查我的 iphone 应用程序中是否没有内存泄漏?或者如何找到并修复它们?
回答by Robin
Use instruments: First build and install your app on the simulator. Stop the process again (the red shield where it says "task"), then go to Run->Run with perfomance tool->Leaks. This will start Instruments preconfigured with a Leaks and memory allocation tool. For more info check out Apple's Memory Usage Performance Guidelines (which also has a section on finding leaks): http://developer.apple.com/library/ios/#documentation/Performance/Conceptual/ManagingMemory/ManagingMemory.html
使用仪器:首先在模拟器上构建并安装您的应用程序。再次停止该过程(红色盾牌上写着“任务”),然后转到“运行”->“使用性能工具运行”->“泄漏”。这将启动预先配置了泄漏和内存分配工具的仪器。有关更多信息,请查看 Apple 的内存使用性能指南(其中也有关于查找泄漏的部分):http: //developer.apple.com/library/ios/#documentation/Performance/Conceptual/ManagingMemory/ManagingMemory.html
回答by Andrew
in xcode 5 just go to product -> analyse... then see the list of the memory leaks breakpoint... just go throw the break point and try to release those are not required variable and class object....
在 xcode 5 中只需转到产品 -> 分析...然后查看内存泄漏断点列表... 只需抛出断点并尝试释放那些不需要的变量和类对象....
http://www.streamingcolour.com/blog/tutorials/tracking-iphone-memory-leaks/
http://www.streamingcolour.com/blog/tutorials/tracking-iphone-memory-leaks/
Or
或者
This tool tells you what library is leaking, then you can debug your code as you deem suitable. If it is well organized, you will be able to see immediately what object is leaking and fix the problem with ease.
该工具会告诉您泄漏的是哪个库,然后您可以根据需要调试代码。如果组织得当,您将能够立即看到泄漏的对象并轻松解决问题。
回答by Aurum Aquila
Why it's simple! Just run the leaks performance tool. Press the following: Run -> Start with Performance Tool -> Leaks.
为什么简单!只需运行泄漏性能工具。按以下操作:运行 -> 使用性能工具启动 -> 泄漏。
This tool tells you what library is leaking, then you can debug your code as you deem suitable. If it is well organized, you will be able to see immediately what object is leaking and fix the problem with ease.
该工具会告诉您泄漏的是哪个库,然后您可以根据需要调试代码。如果组织得当,您将能够立即看到泄漏的对象并轻松解决问题。
Good luck :)
祝你好运 :)
回答by Sorin Antohi
You can try to use the tools from XCode, Leaks tool, CPU sampler, Allocations, Activity monitor.You can find them in the menu Run->Run with performance tools.
您可以尝试使用 XCode 中的工具、Leaks 工具、CPU 采样器、分配、活动监视器。您可以在菜单 Run->Run with performance tools 中找到它们。
It would be ideal to have a device attached to your machine in order to run the tools over the installed app.
将设备连接到您的机器以便在已安装的应用程序上运行工具是理想的。
Here you'll find an introduction to Instruments.
在这里,您将找到Instruments的介绍。