iPhone:多次自动释放对象

发布于 2024-12-23 14:32:41 字数 74 浏览 6 评论 0原文

如果我多次保留一个对象会发生什么。然后,会自动释放一次,当自动释放池耗尽时将其从内存中删除;或者我是否必须像保留它一样多次自动释放它?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最好是你 2024-12-30 14:32:41

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文