send -release或-drain到Autorelease Pool有什么区别? [英] What's the difference between sending -release or -drain to an Autorelease Pool?

查看:229
本文介绍了send -release或-drain到Autorelease Pool有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在许多书籍和许多网站上,我看到了-drain。那么,对于一个声音酷的Autorelease池。但它除了发布之外做什么?我会猜测-drain只是使池释放它的所有对象,而不释放池本身。注意,对oxigen的回答说,-drain不释放NSAutoreleasePool是不正确的注释。

解决方案。 NSAutoreleasePool 的文档清楚地说明-drain是NSAutoreleasePool对象使用-release的替代品,唯一的区别在于,它提供了一个提示,用于指示NSAutoreleasePool对象是否已经被释放(这样就破坏了NSAutoreleasePool)。



<垃圾收集系统。


In many Books and on many Sites I see -drain. Well, for an Autorelease Pool that sounds cool. But does it do anything other than an release? I would guess -drain just makes the Pool to -release all it's objects, without releasing the Pool itself. Just a guess.

解决方案

Note that the comments on oxigen's answer saying that -drain does not release the NSAutoreleasePool are not correct. The documentation for NSAutoreleasePool clearly says that -drain releases (and thus destroys) the NSAutoreleasePool.

-drain is a replacement for using -release for NSAutoreleasePool objects, the only difference being that provides a hint to the garbage collection system.

这篇关于send -release或-drain到Autorelease Pool有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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