使用堆镜头分析显示内存地址,但不显示代码行。如何确定导致堆增长的原因? [英] Using heap shot analysis shows memory addresses, but not lines of code. How do I determine what is causing the heap to grow?

查看:95
本文介绍了使用堆镜头分析显示内存地址,但不显示代码行。如何确定导致堆增长的原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我差不多完成了我的应用程序,并且在提交到应用程序商店之前,我正在使用Instruments来优化性能。我注意到每当我执行特定操作(从外部服务器更新我的应用程序中的信息)时,我的堆增长大约350 KB。我在stackoverflow和Apple的文档中发现的研究建议执行Heap镜头来查找有问题的代码。但是,不是把我带到有问题的代码,而是向我显示内存地址。

I'm nearly finished with my app and I'm using Instruments to optimize performance before I submit to the app store. I noticed that whenever I execute a particular action (updating the information in my app from an external server) my heap grows by about 350 KB. The research I found here on stackoverflow and Apple's documentation suggests executing Heap shots to find the offending code. However, instead of taking me to the offending code it shows me memory addresses.

有没有办法使用这些信息?或者我应该使用其他工具?我对仪器很新,所以我很感激任何帮助。

Is there a way to use this information? Or should I be using another tool? I'm pretty new with Instruments, so I appreciate any help.

我会显示截图,但我的声誉还不够高。

I would show a screenshot, but my reputation here isn't high enough yet.

推荐答案

一些想法:


  1. 在堆镜头中,不要忘记在最右边的面板中显示扩展细节( + E 或从视图菜单中选择扩展细节)仪器。

  1. In the heap shot, don't forget to show the extended detail (+E or select "Extended Detail" from the "View" menu) in the rightmost panel of Instruments.

查看扩展详细信息时,它会显示堆栈跟踪,您可以在那里双击您的方法名称(这将是黑色而不是你会被带到产生分配的那一行(这显然不是根本问题,但它会告诉你最初分配对象的位置,这是一个可以开始的地方)。

When viewing extended detail, it will show you a stack trace, and you can double-click on your method name there (which will be in black rather than light gray) and you'll be taken to the line that generated the allocation (which obviously isn't necessary the root problem, but it will show you where the object was originally allocated, which is a place to start).

话虽如此,我一般都会关注首先是标准的分配工具。我将在顶部的分配工具时间轴中选项 -drag突出显示在此执行时间窗口内的分配,然后我将选择调用树,并专注于我的代码,I检查反转调用树和隐藏系统库框:

Having said that, I generally focus on the standard Allocations tool first. I'll option-drag in the allocations instrument timeline at the top to highlight allocations within this time window of execution, I'll then select "Call Tree", and to focus on just my code, I'll check the "Invert Call Tree" and "Hide System Libraries" boxes:

对我来说,我发现这是一种更有效的方法来识别在该时间窗口内发生的分配没有筛选系统分配。

For me, I find that's a more efficient way of identifying my allocations that took place within that window of time, without sifting through system allocations.

不要忘记通过Xcode中的静态分析器运行代码( shift + + B 或选择产品菜单上的分析。在您开始通过仪器运行应用程序之前,您应该获得一份干净的健康状况。

Do not forget to run your code through the static analyzer in Xcode (shift++B or choose "Analyze" on the "Product" menu). You should get a clean bill of health there before you even start running your app through Instruments.

这篇关于使用堆镜头分析显示内存地址,但不显示代码行。如何确定导致堆增长的原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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