• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Fast Enumeration and temporary objects/autoreleasing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Fast Enumeration and temporary objects/autoreleasing
      • From: Graham Cox <email@hidden>
References: 
 >Fast Enumeration and temporary objects/autoreleasing (From: Patrick Robertson <email@hidden>)
 >Re: Fast Enumeration and temporary objects/autoreleasing (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Resizing UITableView will keeping content scrolled to bottom
  • Next by Date: tips on managing group rows
  • Previous by thread: Re: Fast Enumeration and temporary objects/autoreleasing
  • Next by thread: Re: Fast Enumeration and temporary objects/autoreleasing
  • Index(es):
    • Date
    • Thread