• 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: NSEnumerator retaining objects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSEnumerator retaining objects?


  • Subject: Re: NSEnumerator retaining objects?
  • From: John Stiles <email@hidden>
  • Date: Wed, 9 Mar 2005 10:48:39 -0800

On Mar 8, 2005, at 10:12 PM, mmalcolm crawford wrote:

As far as I can tell, an NSEnumerator does not retain the collection per se. -nextObject does, however, retain and autorelease the object returned.

This clearly has implications for performance as well as memory management...

I must be missing something. How does [[myObj retain] autorelease] affect performance?
[myObj retain] incurs the overhead of:
objc_msgSend
retainCount++

[myObj autorelease] incurs the overhead of:
objc_msgSend
add one entry to the autorelease pool--it's unspecified how NSAutoreleasePool stores its entries but it is likely to be very fast

Later on when the event loop drains, you have the overhead of:
objc_msgSend
retainCount--
compare retainCount with zero (it's non-zero since it was retained above)

So it's not zero overhead, sure, but I honestly wouldn't expect any of this to affect real-world performance measurements. Certainly not enough overhead to generate this much list traffic.
So is there another performance implication I'm missing?
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSEnumerator retaining objects?
      • From: James Bucanek <email@hidden>
    • Re: NSEnumerator retaining objects?
      • From: j o a r <email@hidden>
References: 
 >Re: NSEnumerator retaining objects? (From: James Bucanek <email@hidden>)
 >Re: NSEnumerator retaining objects? (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: Autorelease accessors, was Re: NSEnumerator retaining objects?
  • Next by Date: Re: NSEnumerator retaining objects?
  • Previous by thread: Re: Autorelease accessors, was Re: NSEnumerator retaining objects?
  • Next by thread: Re: NSEnumerator retaining objects?
  • Index(es):
    • Date
    • Thread