The @autoreleasepool does the same job as before, instead of using the NSAutoreleasePool class. NSAutoreleasePoolโs way of working was a little strange, since creating it had an effect throughout the application; @autoreleasepool creates a scope with a scope and gives a clearer picture of what is inside the pool and when it merges (when it goes out of scope). It is also more efficient according to Apple.
The concept of the autoresist pool is simple, whenever an instance of an object is marked as auto-implemented (for example, NSString* str = [[[NSString alloc] initWithString:@"hello"] autorelease]; ), it will have a hold value of +1 at this point in time , but at the end of the loop, the pool merges, and any object marked with autorelease then has a save account reduced. This is a way to keep the object around while you cook everything that will keep it for yourself.
With ARC, while the autorelease keyword is not used by the developer, the base system that manages ARC inserts is for you. ( Remember: all ARC inserts retain , release and autorelease calls you at the appropriate times.) Because of this, the existing AutoreleasePool concept must remain.
If you delete the auto resource pool, your objects will start to leak
In a link-counting environment, Cocoa expects the auto-ad pool to always be available. If the pool is unavailable, auto-implemented objects are not freed and you skip memory. In this situation, your program usually records the appropriate warning messages.
WDUK Feb 03 '13 at 20:58
source share