Re: Nib & retainCount confusion
Re: Nib & retainCount confusion
- Subject: Re: Nib & retainCount confusion
- From: Uli Kusterer <email@hidden>
- Date: Wed, 3 Oct 2007 18:42:59 +0200
Am 03.10.2007 um 09:05 schrieb email@hidden:
Is my controller class being retained through bindings somehow? The
same controls that the NSObjectController are bound to are also
present in my controller class as IBOutlets. I set them to nil when
I want to release the object. Ugh. Any thoughts on what I am doing
wrong?
Depends on what is being bound to what. When an object observes
another using KVO, it retains the observed object. So, if you have a
controller that creates (and thus owns) another object, and that
object observes the controller, then you'll probably get a retain
circle that prevents either of them from being released, because each
of them waits for the other to release it.
(Or something like that, this kinda reads weird, so maybe it was
the other way round)
Anyway, there was a lot of hoopla around such a retain circle that
was very easy to produce, so you may want to look up in the docs who
is documented to retain whom and see whether this could be happening
in your case and whether that's a problem.
Having a retain count of 2 and an object not immediately released
even though *you* did all your releases isn't necessarily a leak, of
course, since the whole point of reference counting is that several
parties can hold on to an object without either having to care about
releasing something the other still needs. Also, if even one of them
called autorelease, it could simply take a little while until the
pool gets flushed (the OS occasionally doesn't delete its autorelease
pool from an old event until it has actually received a new one, so
your object may still be around until the next click or so).
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
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