Re: Intercepting retain/release of object
Re: Intercepting retain/release of object
- Subject: Re: Intercepting retain/release of object
- From: "Sherm Pendley" <email@hidden>
- Date: Fri, 21 Mar 2008 16:16:06 -0400
On Fri, Mar 21, 2008 at 2:13 PM, Scott Ribe <email@hidden>
wrote:
> If you really want to understand what's going on, forget the counts, set
> breakpoints on your overloaded retain & release methods, then look at the
> stack trace every time. It may take a while, because there may be a lot
> going on behind the scenes, but it's one way to get an understanding.
> (Also
> add an override for autorelease.)
I think it's worth keeping in mind that such a deep understanding is very,
very rarely necessary to begin with. The memory management guidelines are
actually very clear. The most common memory-management mistake is sprinkling
memory-management code around more or less at random, instead of
encapsulating it in easy-to-understand accessors. The second most common is
confusing the heck out of one's self by looking "under the hood" in an
attempt to fix the first kind of mistake.
If you only retain and/or release in your accessors, and then consistently
use those accessors instead of assigning directly to ivars, then you'll
usually have no need to examine retain counts to debug any leaks - all you
need to do is make sure the accessors are correct.
sherm--
_______________________________________________
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