There's also a high cost, in CPU cycles and memory, to retain/ [auto]release in such an excessively defensive way. And have fun using Object Alloc to find real problems once you've added these superfluous retain/release/autoreleases to every return value in your entire program.

But wouldn't adding those retain/autoreleases to every accessor in your entire program have the same effect?

Perhaps to an extent, if the object in question lives a long time relative to the number of gets of it. But in any case, the same object may be passed down a very long callstack, so the difference could be between a single retain]autorelease] and a thousand of them.

It's still easier to interpret in tools like Object Alloc, though - you can clearly see the retain]autorelease] for each getter scattered throughout other uses. The periods you're most interested in are likely to be between calls to the getter (on the same thread, at least), and so much less noisy.

Wade
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to