如何修复iOS应用程序中的内存泄漏? [英] How to fix memory leaks in iOS applications?

查看:106
本文介绍了如何修复iOS应用程序中的内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行应用程序时发现很少的内存泄漏.供您参考,我将分享Instrument调试日志和Xcode Debugg内存图工具的屏幕截图.我没有弄明白这里出了什么问题.请帮助我解决内存泄漏.

I have found few memory leaks when I am running my application. For your reference, I am sharing the screenshots of Instrument debug logs and also Xcode Debugg memory graph tool. I am not getting what is going wrong here. Please help me to resolve memory leaks.

请帮助我修复图像中的内存显示.谢谢.

Please help me to fix the memory shows in the image. Thank you.

推荐答案

您不需要使用乐器.那是老方法.使用Xcode本身.

You do NOT need to use Instruments. That's the old way. Use Xcode itself.

请参见使用Xcode进行视觉调试 -24:45

See Visual Debugging with Xcode - 24:45

必须观看视频,但视频摘要如下:

Watching the video is a MUST, but the summary of the video is as such:

有两种类型的内存问题.您只需在应用程序中重复2-3次流程,以确保内存图已捕获到它

There are two type of memory problems. You just have to repeat a flow in your app 2-3 times to be certain the memory graph has caught it

  • 泄漏. Xcode将使用紫色图标对此进行注释.可能是:委托,闭包
  • 被遗弃的内存. Xcode不会对此进行注释.但这仍然会增加您的内存占用量.可能的示例包括:永不失效的重复计时器,NotificationCenter,永无休止的DispatchWorkItem

对于泄漏,内存图是一个循环,即两种方式.

For Leaks the memory graph is a loop ie two way.

对于被遗弃的内存,图形不是两种方式. Apple只是一个对象,将其归类为根路径",它引用了您的对象并且永不放弃.有关更多信息,请参见此处

For Abandoned memory the graph is NOT two way. It's just an object one that Apple categorizes as 'root path' referencing your object and never letting it go. For more on this see here

这篇关于如何修复iOS应用程序中的内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆