gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: r27812 - in /libs/gui/trunk: ChangeLog Source/NSBundleAdditions.m


From: Wolfgang Lux
Subject: Re: r27812 - in /libs/gui/trunk: ChangeLog Source/NSBundleAdditions.m
Date: Tue, 2 Mar 2010 09:24:28 +0100

Author: fredkiefer
Date: Sun Feb  8 13:54:21 2009
New Revision: 27812

URL: http://svn.gna.org/viewcvs/gnustep?rev=27812&view=rev
Log:
Use KVC call setValue:forKey: to establish the outlet connection.
This will result in ivars being properly retained.

Modified:
    libs/gui/trunk/ChangeLog
    libs/gui/trunk/Source/NSBundleAdditions.m


Hi Fred,

it's been a while since you've committed this change, but I just got round yesterday evening to track down a major space leak to exactly this change: Windows (and apparently other entities) loaded from a nib file never get released and deallocated. As an example, try this with Ink:
- Open the memory panel from the info panel.
- Open a new document window.
- Update the memory panel. The panel now shows one (new) NSWindow, one (new) Document, etc.
- Close the document window.
- Update the memory panel. The Document and NSWindowController instance are gone, the NSWindow is still alive. If you revert your change, the NSWindow and its views are properly released.

At first, I was assuming that your change is correct and the nib loading code was improperly retaining the top-level entities. However, the longer I think about it the more I am convinced that it is your change that is wrong. In fact we do *not* want to retain ivars in general. It is well documented by Apple that only ivars that reference top-level entities of a nib are owned by the receiver (and this is already handled properly by the nib loading code), other ivars are not owned. An example for this is the tv attribute of Ink's Document objects. This attribute must not be retained when the connection is instantiated. Otherwise, the text view would not be released even when the window were released and deallocated when its document is closed. [1]

Wolfgang

[1] You can trivially test this without reverting your change by adding the statement [[aController window] autorelease] to the Document -windowControllerDidLoadNib: method. Now the window is deallocated when it is closed, but its text view still remains alive.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]