Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the scope of (nested) autorelease pools?

I'm creating an autorelease pool in a for loop (in method A). At each iteration of the loop, I'm calling another method (method B). Method B returns an autoreleased object to Method A. If I drain the pool within the for loop in Method A, will that release the objects sent from Method B?

Thanks!

like image 538
infiniteloop Avatar asked Feb 28 '23 08:02

infiniteloop


1 Answers

Yes - any time an object is sent -autorelease, it's added to the highest level autorelease pool. As long as you aren't creating any new autorelease pools in method B or further down the call stack, method A's pool should be the highest level pool.

like image 182
pix0r Avatar answered Mar 07 '23 20:03

pix0r