Home > DeveloperSection > Interviews > What do you mean by Autorelease pool - Drain Vs Release

Posted on    August-11-2015 11:33 PM

 iPhone iPhone  Ios  Objective C 
 1 Answer(s)
  600  View(s)
Rate this:

Nigel Bunyan
Nigel Bunyan

Total Post:4

Posted on    August-11-2015 11:33 PM

In a reference-counted environment, drain does perform the same operations as release, so the two are in that sense equivalent. To emphasise, this means you do not leak a pool if you use drain rather than release.


In a garbage-collected environment, release is a no-op. Thus it has no effect. drain, on the other hand, contains a hint to the collector that it should "collect if needed". Thus in a garbage-collected environment, using drain helps the system balance collection sweeps.

Don't want to miss updates? Please click the below button!

Follow MindStick