Re: Debugging complex autorelease/release/retain issue
Re: Debugging complex autorelease/release/retain issue
- Subject: Re: Debugging complex autorelease/release/retain issue
- From: Matt Neuburg <email@hidden>
- Date: Mon, 20 Nov 2006 08:23:47 -0800
- Thread-topic: Debugging complex autorelease/release/retain issue
On Sun, 19 Nov 2006 17:12:59 -0800, Skip Haughay <email@hidden> said:
>I have a leak in my code I am attempting to chase down, and in doing so, I need
some clarification of the behavior of autorelease pool objects. In order to
debug my class memory cycle, I overrode the following:
>
>+ (id) alloc // Added NSLog to indicate object allocation to console
>- (void) dealloc // Added NSLog to indicate object deallocation to console
>- (id)retain // Added NSLog to indicate retain call, plus show the
retainCount to console
>- (void)release // Added NSLog to indicate release call, plus show the
resulting retainCount
Another way is to use ObjectAlloc. If you ask it to watch memory management
and retain backtraces, then you can run your app to the point where the leak
occurs, pause, and read directly the entire alloc/retain/release history of
a particular object, using the inspector window to read the backtrace so you
know who did it. Unfortunately the retain count is not shown, so you have to
whip out a pencil and paper and copy down all the information and then start
pairing up alloc/retains and releases to see where the imbalance lies. But
my experience is that once you've drawn the necessary diagram you'll see the
source of the leak instantly. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden