Re: garbage collection and NSConnection
Re: garbage collection and NSConnection
- Subject: Re: garbage collection and NSConnection
- From: Marcel Weiher <email@hidden>
- Date: Fri, 11 Jul 2008 11:17:19 -0700
On Jul 11, 2008, at 8:59 , Michael Ash wrote:
The cost of a single refcounting op is negligible compared to the
cost of
object allocation, so these two are quite irrelevant.
A quick test of this claim would appear to disprove it. On my Mac Pro,
an alloc/init/release cycle of NSObject costs about 290ns. Adding an
extra pair of retain/release costs about 480ns. I'm not sure how I can
reasonably measure the object allocation by itself, or the cost of
just retain or just release. But it seems clear that these refcounting
operations are quite significant in cost.
This is the extra refcount table in action, and why inline reference
counts can be such a performance win on objects that are frequently
retained and released.
Changing the object to an NSString (which has an internal reference
count) yields the following results on my MacBook Pro:
retain+release NSString: time per iteration: 67 nanoseconds
Compare this with the times for NSObject, both retain/release and
allocation / deallocation:
retain+release NSObject 2->3 / 3->2 : time per iteration: 223
nanoseconds
retain+release NSObject 1->2 / 2->1 : time per iteration: 276
nanoseconds
alloc+dealloc NSObject: time per iteration: 415 nanoseconds
Cheers,
Marcel
[EOT for me]
[Differences of opinion and experience snipped]
_______________________________________________
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