文档里是这么说的:
drain
In a reference-counted environment, releases and pops the receiver; in a garbage-collected environment, triggers garbage collection if the memory allocated since the last collection is greater than the current threshold.
Discussion
In a reference-counted environment, this method behaves the same as release
. Since an autorelease pool cannot be retained (see retain
), this therefore causes the receiver to be deallocated. When an autorelease pool is deallocated, it sends a release
message to all its autoreleased objects. If an object is added several times to the same pool, when the pool is deallocated it receives a release
message for each time it was added.
In a garbage-collected environment, this method ultimately calls objc_collect_if_needed
.
Special Considerations
In a garbage-collected environment, release
is a no-op, so unless you do not want to give the collector a hint it is important to use drain
in any code that may be compiled for a garbage-collected environment.