帮助查找内存泄漏(一般提示) [英] Help finding memory leaks (general tips)

查看:112
本文介绍了帮助查找内存泄漏(一般提示)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是在iOS上,设备是iPad。

This is on iOS, device is iPad.

以下是发生的事情:


  1. 我在设备上运行应用程序或调试并使用Xcode运行。

  2. 5分钟后,我收到1级内存警告。

  3. A一分钟后,我收到2级记忆警告。

  4. 再过一分钟,收到信号:0。

  1. I run app on device or debug and run using Xcode.
  2. After 5 minutes I receive a memory warning of level 1.
  3. A minute later I receive a memory warning of level 2.
  4. Another minute later, Program received signal: "0".

我使用仪器泄漏检查泄漏,检测到没有泄漏
但是,根据活动监视器,我的应用程序最初使用30 MB,并且随着时间的推移增长到超过100mb(大约每秒200kb!)。所以,Leaks显然没有检测到所有内存泄漏。

I checked for leaks using Leaks in Instruments and detected no leaks. However, according to Activity Monitor, my app initially uses 30 MB, and grows in size to over 100mb over time (about 200kb per second!). So, apparently Leaks doesn't detect all memory leaks.

所以我的问题是:如果Leaks无法检测到它,是否有找到它们的一般提示,并且有更好的工具可以找到这些泄漏吗?

So my question: if Leaks can't detect it, are there any general tips to finding them, and is there a better tool to find these leaks?

推荐答案

这就是我接近它的方式,

This is how I would approach it,


  1. 使用前缀为所有类命名,以便在工具中轻松查看

  1. Name all you classes with a prefix so you can easily see them in Instruments

XCode-> Run->使用性能工具运行 - >分配

XCode->Run->Run with performance tool->allocations

现在停止你的应用程序并输入类的名称你怀疑在搜索框中泄漏了。 (这是前缀很方便的地方)。启动仪器再次使用记录按钮

Now stop your app and type the name of class you suspect is leaking in the search box. (this is where the prefix is handy). The start instruments again with the "Record" button


  1. 在分配对象时,活动列应该上下移动。请注意,如果它没有泄漏,你就会有泄漏。

这篇关于帮助查找内存泄漏(一般提示)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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