1. NSAID utoreleasepool is actually an automatic processor of object reference count. The NSAID utoreleasepool can have multiple nodes at the same time, and its organization is a stack. There is always a stack top pool, that is, the current pool. Every time a pool is created, one pool is pressed into the stack, change the current pool to the new pool. Then, each time a drain message is sent to the pool, the pool at the top of the stack pops up, and change the current pool to the next pool in the stack.
2. In the main function of the program entry, the NSAID pool is called. This ensures that the program does not call the NSAID pool, but is automatically released upon exit. It is best to implement NSAID utoreleasepool for new threads
3. The management scope of the NSAID utoreleasepool is the object between the NSAID utoreleasepool * Pool = [[NSAID utoreleasepool alloc] init]; and [pool release ];
4. NSAID utoreleasepool * Pool = [[NSAID utoreleasepool alloc] init];
When the [pool autorelease] is executed, the system releases the autorelease object once again. If there is no NSAID utoreleasepool, the memory will not be released.
Note: The object is not automatically added to the current pool, but needs to send the autorelease message to the object. In this way, the object is added to the management of the current pool. When the current pool receives a drain message, it simply sends a release message to all objects it manages.
For example
NSAID utoreleasepool * Pool = [[NSAID utoreleasepool alloc] init];
Nsstring * nsstring;
Char * cstring = "Hello cstring ";
Nsstring = [nsstring stringwithuf8string: cstring];
[Pool release];
5. The alloc object must be displayed and released.
For example:
NSAID utoreleasepool * Pool = [[NSAID utoreleasepool alloc] init];
Nsstring * string = [[nsstring alloc] init];
[String stringbyappendingstring: @ "Hello world! "];
[Pool release];
[Nsstring release];