如何在调试时检查保留计数
有谁知道如何在调试模式下检查对象的保留计数?我尝试添加表达式 [objInstance keepCount]
但它不起作用。我还在控制台中尝试了打印对象 PO [objInstance keepCount]
,但它再次不起作用。
Does anybody know how can I check the retain count of an object while in debug mode? I have tried to add an expression [objInstance retainCount]
but it did not work. I have also tried the print object PO [objInstance retainCount]
in the console but again it did not work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜你正在谈论在
GDB
中获取retainCount
?您可以使用
retainCount
方法。这就是我进入代码的方式。
希望这就是您正在寻找的。
I am guessing you are talking about getting the
retainCount
inGDB
?You can use the
retainCount
method.This is how I get in my Code.
Hope this is what you are looking for.
您可以使用以下命令打印此数字
。但是,由于
autorelease
等原因,该数字并不可靠。您应该阅读内存管理 并确保您的retain
和release
调用匹配。您还可以运行“Build/Build”和“Analyze”来让 Xcode 帮助您找到可能的内存泄漏,但同样,这些只是潜在的泄漏。您需要亲自检查每一项才能确定。You can print this with
However, this number isn't reliable due to things like
autorelease
. You should rather read up on memory management and make sure that yourretain
andrelease
calls match up. You can also run Build/Build and Analyze to get Xcode to help you find possible memory leaks, but again, these are only potential leaks. You'll need to check each one yourself to be sure.