✍️ Note
Some codes and contents are sourced from Apple’s official documentation. This post is for personal notes where I summarize the original contents to grasp the key concepts
What is Autorelease Pool?
An object that supports Cocoa’s reference-counted memory management system.
An autorelease pool stores objects that are sent a
releasemessage when the pool itself is drained.If you use Automatic Reference Counting (ARC), you cannot use autorelease pools directly. Instead, you use
@autoreleasepoolblocks.
@autoreleasepoolblocks are more efficient than using an instance ofNSAutoreleasePooldirectly; you can also use them even if you do not use ARC.https://developer.apple.com/documentation/foundation/nsautoreleasepool

AutoRelease Pool
You can send multiple autorelease message to an object. When autorelease pool released, object will receive multiple release message.


Common Scenario when Is it useful for? -> Created an object in a Loop!
for (i=0; i < MANY_TIMES; i++)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//Create an object and send autorelease message
MyObject *object = [[MyObject alloc] init];
[object autorelease];
//Release all objects that created in this loop.
[pool release];
}

Leave a Reply