Re: Speed Traps
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.