Re: Fast Enumeration and temporary objects/autoreleasing
Re: Fast Enumeration and temporary objects/autoreleasing
- Subject: Re: Fast Enumeration and temporary objects/autoreleasing
- From: Dave Zarzycki <email@hidden>
- Date: Mon, 16 Apr 2012 22:47:46 -0400
On Apr 16, 2012, at 8:10 PM, Graham Cox <email@hidden> wrote:
> Memory management is really quite straightforward, and consists of a few rules that everything follows (the framework invariably does; your code should do).
If that were true, then ARC would not have been necessary.
> On 16/04/2012, at 7:42 PM, Patrick Robertson wrote:
>
>> so are these temp objects created during the enumeration released
>> automatically at the end of the loop, or is it work wrapping the whole
>> thing in an autoreleasepool?
No implicit pools are created.
When it comes to autorelease pools, we primarily see them as a performance tuning technique. If your code is not running into performance problems and if the documentation does not explicitly tell your code to use a pool (say for use with NSThread), then please don't worry about it.
And if you are running into performance problems on a per iteration basis, then please remember that the rules of C allow you to write code like this to avoid double indenting:
for (id anObject in anArray) @autoreleasepool {
// do stuff
}
do @autoreleasepool {
// do stuff
} while (x);
while (x) @autoreleasepool {
// do stuff
}
davez
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden