0 votes
12 views

What are NSAutoreleasePool? When to use them?

in Technology by (190k points)

1 Answer

0 votes

The NSAutoreleasePool class is used to support Cocoa’s reference-counted memory management system. An autorelease pool stores objects that are sent a release message when the pool itself is drained.

Also, If you use Automatic Reference Counting (ARC), you cannot use autorelease pools directly. Instead, you use @autoreleasepool blocks. For example, in place of:

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

// Code benefitting from a local autorelease pool.

[pool release];

You would write:

@autoreleasepool

{

// Code benefitting from a local autorelease pool.

}

@autoreleasepool blocks are more efficient than using an instance of NSAutoreleasePool directly; you can also use them even if you do not use ARC.

by (190k points)

Related questions

0 votes
1 answer 11 views
0 votes
1 answer 11 views
11 views asked Nov 10, 2020 in Technology by JackTerrance (190k points)
0 votes
1 answer 14 views
0 votes
1 answer 28 views
0 votes
1 answer 12 views
12 views asked Nov 10, 2020 in Technology by JackTerrance (190k points)
0 votes
1 answer 14 views
0 votes
1 answer 11 views
11 views asked Nov 10, 2020 in Technology by JackTerrance (190k points)
0 votes
1 answer 10 views
0 votes
1 answer 10 views
10 views asked Nov 10, 2020 in Technology by JackTerrance (190k points)
0 votes
1 answer 12 views
0 votes
1 answer 14 views
0 votes
1 answer 11 views
0 votes
1 answer 33 views
0 votes
1 answer 16 views
16 views asked Nov 10, 2020 in Technology by JackTerrance (190k points)
0 votes
1 answer 14 views
...