Re: Window Controller not being released.
Re: Window Controller not being released.
- Subject: Re: Window Controller not being released.
- From: James DiPalma <email@hidden>
- Date: Sat, 26 Oct 2002 16:38:44 -0700
I can tell you that you don't need to worry about NSConnection. That
class is only used during NIB loading, and the AppKit releases them
when done.
On the contrary, I believe NSConnection is what is actually giving me
my problems.
I think Dustin meant to say NSNibConnector; which is different from
NSConnection.
I don't know what your problem is, but these first 3 steps should not
be causing any problems.
1.) in the Document's makeWindowController method, I allocate the
controller ([[controller alloc] initWithNibName]) which sends a retain
request
2.) I call [document addWindowController]
3.) I manually release the window controller from step 1
So, something must be causing problems elsewhere (I'm guessing you
already knew this bit though).
when I call [NSConnection connectionWithReceivePort:sendPort] the
NSConnection should be autoreleased, should it not?
Yes.
If the NSConnection isn't being properly released, could it be hanging
on to an instance of the controller, since the controller is the
connection's rootObject?
I hope NSConnection is retaining its root object. Can't confirm it
right now (lack of initiative).
If so, how do I make sure the connection is properly released??
I don't know and would like to help, but I'm looking at my thread
connection code and I'm thinking that my code leaks too. And I should
fix it, but I can't help much except to make suggestions like
- make sure that you call connectionWithReceivePort:... from within an
autorelease pool (almost certainly not your problem because your code
would log an error for autoreleasing without a pool).
- try calling setRootObject:nil (I have not tried to do this, but if
your connection is retaining your controller, this call might let go,
but you'll still leak a connection if your ultimate problem is a leaked
NSConnection). A potential temporary fix.
My other suggestion and real reason for responding is to suggest
separating your NSWindowController into a class that controls your
window and an NSObject subclass that controls views within your window.
This suggestion would only localize your problem and not fix it, but
your image controller would be isolated from document architecture and
may help to simplify fixing problems like this (e.g. your questions
about removeWindowController would not apply).
Good luck with everything.
-jim
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.