在Obj-C中查找对对象实例的所有引用 [英] Finding all references to an object instance in Obj-C

查看:94
本文介绍了在Obj-C中查找对对象实例的所有引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图找出一些错误,其中一个与内存泄漏有关.我可以说这是一个对象,因为Instruments仍然显示它是活的,但是Instruments并未将其注册为泄漏.

I'm trying to track down some bugs, and one of them is related to a memory leak. It's an object that I can tell that something still has a reference to, since Instruments still shows it as being alive, but Instruments does not register it as a leak.

总有没有办法在Objective-C中查看某个对象的实例,看看还有哪些其他对象对该对象有引用?

Is there anyway to look at an instance of an object in Objective-C and see what other objects still have a reference to that object?

推荐答案

我建议使用Allocations/ObjectAllocations Instruments模板,然后在右上角键入对象的类名(在Category字段中).

I would recommend using the Allocations/ObjectAllocations Instruments template and then in the top right corner type the class name of your object (in the Category field).

然后您可以看到分配的建议,并通过查看扩展的详细信息来查看分配的位置.

You can then see the allocations increasing as you suggest and by viewing the extended detail you can see where they were allocated.

此后所有内容均由OP添加( joshbuhler )

All content below this point was added by the OP (joshbuhler)

在下面的屏幕截图中,将过滤器更改为对象列表",然后单击对象地址右侧的小箭头,将显示内存事件的历史记录(分配/保留/释放/释放)对于那个对象.它不会告诉您确切挂在该对象上的内容,但是它将为您提供一些非常有用的信息以进行跟踪.

In the screenshot below, change the filter to "Objects List", and then by clicking on the little arrow to the right of the object's address, the history of memory events (alloc/retain/release/dealloc) will be show for that object. It won't show you exactly what is hanging onto that object, but it will give you some very useful info for tracking it down.

这篇关于在Obj-C中查找对对象实例的所有引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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