返回时自动释放时泄漏
我发现了这个奇怪的事情。 XCode 仪器告诉我这条线
return (SDZPerson*)[[[SDZPerson alloc] initWithNode: node] autorelease];
存在泄漏。但如果我将其更改为:
SDZPerson* person = [[[SDZPerson alloc] initWithNode: node] autorelease];
return person;
仪器不再报告此位置的泄漏。到底是真的漏了还是什么都没有?
预先感谢大家。
I found this strange thing. XCode instruments tell me that this line
return (SDZPerson*)[[[SDZPerson alloc] initWithNode: node] autorelease];
leaks. But if i change it to:
SDZPerson* person = [[[SDZPerson alloc] initWithNode: node] autorelease];
return person;
Instruments no longer report leak in this place. Is it really a leak or is it nothing?
Thank you all in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
即使两个代码片段略有不同(第一个代码片段包含类型转换),我怀疑仪器会因为 return 语句中的自动释放而将其指示为泄漏。
可以使用return语句中添加autorelease。
你应该尝试一下
,甚至
Even if the two code snippets are slightly different (the 1st one contain a typecasting), I doubt the instruments indicate this as a leak due to the autorelease in the return statement.
Adding autorelease in the return statement can be used.
You should give it a try to
or even