Re: Release vs. autorelease
Re: Release vs. autorelease
- Subject: Re: Release vs. autorelease
- From: Dave Carrigan <email@hidden>
- Date: Mon, 12 Jan 2009 12:05:50 -0800
On Jan 12, 2009, at 11:37 AM, Mohan Parthasarathy wrote:
In places other than dealloc where memory needs to be released (e.g,
reassigning pointer to objects), is there a difference in doing
autorelease
or release of the object in terms of perfomance etc. ? I can see
that the
memory is released immediately in one case whereas in the other it is
slightly delayed. Is there any other difference ? What is the right
thing to
do ?
autorelease would take slightly longer because in addition to the
actual release that is eventually called, there is the overhead of
adding the object to the autorelease pool. Except inside really tight
loops this would likely not even be noticeable.
Another factor is that if the pool doesn't get drained for a while,
your app's working set will be higher than if you had used release.
Again, probably a negligible difference except in edge cases.
From a style perspective, I would probably use release, because I
think it describes my intention better - I'm saying that I absolutely
don't need this object any more.
--
Dave Carrigan
email@hidden
Seattle, WA, USA
Attachment:
PGP.sig
Description: This is a digitally signed message part
_______________________________________________
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