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 protected]
Seattle, WA, USA

Attachment: PGP.sig
Description: This is a digitally signed message part

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to