• 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: Speed Traps
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Speed Traps


  • Subject: Re: Speed Traps
  • From: Marcel Weiher <email@hidden>
  • Date: Fri, 16 May 2003 21:51:09 +0200

The way autoreleases pools are implemented is (essentially) as a list of objects (it would be very easy to implement them using NSMutableArray, but I don't know if they are done that way).

I am not so sure that retaining the objects in the autorelease pool (which is what NSMutableArray would do) is such a good idea...

Apples docs on the performance of Autorelease pools is somewhat misleading (in my opinion). If you don't allocate anymore objects than you "normally" would the performance is nearly the same as for manually calling release.

This turns out not to be the case. I have done extensive benchmarking of various aspects of Cocoa memory management, including allocation, deallocation, reference counting and pools. Autorelease pools are significantly slower than a plain retain. Of course, NSObject's extra-reference count implementation is so incredibly slow that the difference isn't all that noticeable, but if you've implemented an inline refcount or are using one of the built-in classes, then the difference is very signiifcant.

For example, the "autoreleasing accessor" that is sometimes recommended by Apple happens to be roughly 10 times slower than the "canonical accessor" that just about everyone else recommends.

Marcel

--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Speed Traps
      • From: Kevin Elliott <email@hidden>
References: 
 >Re: Speed Traps (From: Kevin Elliott <email@hidden>)

  • Prev by Date: Re: OT: WWDC
  • Next by Date: newbie question: how to get small icon in NSButton?
  • Previous by thread: Re: Speed Traps
  • Next by thread: Re: Speed Traps
  • Index(es):
    • Date
    • Thread