iPhone:多次自动释放对象
如果我多次保留一个对象会发生什么。然后,会自动释放一次,当自动释放池耗尽时将其从内存中删除;或者我是否必须像保留它一样多次自动释放它?
what happens if i retain an object multiple times. Then, will autoreleasing it once, delete it from the memory when the autorelease pool is drained; or do i have to autorelease it as many times as i retained it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Autorelease 计划在将来的某个时间(即当前自动释放池耗尽时)一次释放对象。因此,如果您多次保留一个对象,您需要(自动)释放它相同的次数来补偿
Autorelease schedules an object to be released once in some time in future (i.e. when current autorelease pool is drained). So if you retain an object several times you need to (auto)release it the same number of times to compensate that