Re: Retain cycle problem with bindings & NSWindowController
Re: Retain cycle problem with bindings & NSWindowController
- Subject: Re: Retain cycle problem with bindings & NSWindowController
- From: "Dennis C. De Mars" <email@hidden>
- Date: Tue, 8 Jun 2004 23:36:50 -0700
On Jun 8, 2004, at 8:33 PM, Allan Odgaard wrote:
On 9. Jun 2004, at 4:49, Dennis C. De Mars wrote:
My solution was to send unbind: messages in the
windowWillClose:-notification.
OK, I can see that this would work. Do you have to send an unbind
message to each view object that has a binding?
At least all those which cause retainment of the involved parties. But
in my case I only had a single binding, so not much of a problem...
[...] If the window controller could be convinced to completely
release the window before it is itself dealloced then the cycle could
be broken but there is no way I know of to do this
You can send setWindow: with nil to the window controller.
Thanks! I missed that possibility. I'm going to try it out, it might
save me from having to go through all that folderol I outlined in my
previous message.
It looks to me like I could override the NSWindowController -close
method and use it there. Well, I'll experiment and see what I can do.
This could be in a response to a 'window will close'-notification.
But there are cases where the window may re-open, and thus one needs
to have the class responsible for releasing the window controller also
perform this workaround.
Anyway, the best thing would be for Apple to fix the binding retain
situation so I would have to go through all this!
Indeed, there is probably a lot of applications out there which
doesn't work around this problem and thus leaks...
Yes! I was thinking the same thing through this entire discussion. This
is probably hitting the vast majority of people using bindings but most
of them just don't realize it. With virtual memory, and disk space and
RAM being what they are nowadays, memory leaks of this kind go
unnoticed -- you have to look to find them. I just combed out most of
the memory leaks from one of my older applications and found more than
I expected. So I figured I would take a look at this new application I
am writing and try to get the memory management right while it is still
in an embryonic state. I was surprised to find, even in its current
primitive state, that there were memory leaks due to bindings. This
will eventually be a pretty complex application, so I want to try to do
things right from the start -- but if I had never looked at it with
ObjectAlloc, I would have been totally oblivious to the memory
management errors.
- Dennis D.
_______________________________________________
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.