in Technology by

What are NSAutoreleasePool? When to use them?

1 Answer

0 votes
by

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.

Related questions

0 votes
    As I understand it, anything created with an alloc, new, or copy needs to be manually released. For ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    What are the Continuous Integration tools, and why is Jenkins better than them?...
asked Oct 1, 2021 in Technology by JackTerrance
0 votes
    What is the user stories in Scrum? What are the advantages of using them?...
asked Aug 19, 2021 in Technology by JackTerrance
0 votes
    You are given a data set consisting of variables with more than 30 percent missing values. How will you deal with them?...
asked Apr 26, 2021 in Technology by JackTerrance
0 votes
    What are the types of Schemas we have in data warehouse and what are the difference between them?...
asked Mar 29, 2021 in Technology by JackTerrance
0 votes
    What are the types of Caches in lookup? Explain them....
asked Mar 28, 2021 in Technology by JackTerrance
0 votes
    What are the different layers in cloud computing? Explain working of them....
asked Dec 15, 2020 in Technology by JackTerrance
0 votes
    What are the different types of object relations in salesforce? How can you create them?...
asked Nov 11, 2020 in Technology by JackTerrance
0 votes
    Are id and instanceType same? If not, what are differences between them in Objective-C?...
asked Nov 10, 2020 in Technology by JackTerrance
0 votes
    What are the products offered by Tableau? Explain a few things about them....
asked Nov 1, 2020 in Technology by JackTerrance
0 votes
    Which of the following technique/techniques is/are used by Einstein on Data to turn them into insights? A. Automate B. Recommend C. Discover D. Predict E. All the options...
asked Nov 1, 2022 in Education by JackTerrance
0 votes
    What are the different memories you know about? Which of them takes the shortest access time? Select the correct answer from above options...
asked Dec 29, 2021 in Education by JackTerrance
0 votes
    what are three types of network and define them with example Select the correct answer from above options...
asked Dec 17, 2021 in Education by JackTerrance
0 votes
    How many data formats are available in Excel? Name some of them. Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
...