iosobjective-cautoreleasensautoreleasepool

Who calls autorelease pool


Who calls autorelease pool or who manages it. I call autorelease on my variable which is inside a function, but who manages this autorelease call, the calling function, or the caller function or who does?


Solution

  • First of all, if you are saying autorelease, don't. Stop using manual memory management and use ARC. It knows more than you do.

    Okay, so let's say you do say autorelease. Then it is placed in the autorelease pool and its retain count remains incremented. Its retain count will be decremented again when the autorelease pool is drained. When that happens depends on what autorelease pool you're talking about.