[Top][All Lists]

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

Re: NSTextView memory leak

From: Richard Frith-Macdonald
Subject: Re: NSTextView memory leak
Date: Sun, 20 Oct 2002 19:13:42 +0100

On Sunday, October 20, 2002, at 06:11  pm, Alexander Malmberg wrote:

Caba Conti wrote:

The following code is from NSTextView's dealloc method:
(CVS version from october 19th)

/* Balance the RELEASE we sent to us to break the retain cycle in initWithFrame: or initWithCoder: (otherwise releasing the _textStorage will make our retain count go below zero ;-) */
          RETAIN (self);

          /* This releases all the text objects (us included) in
           * fall.  */
          DESTROY (_textStorage);

          /* When the rest of the text network is released, we'll be
           * released again and be deallocated for real.  That will
           * likely happen during the DESTROY of the _textStorage, or
           * later if parts of the text network are maybe retained
           * elsewhere (in autorelease pools etc) for slightly longer.

I had a quick look at it, and it seems like the semantic changes in
NSDecrementExtraRefCountWasZero() (and thus -release/-dealloc;
2002-06-01) broke this. If the new behavior is correct, the
RETAIN(self); can simply be removed.

Well, we went into it in enough detail at the time that I think we
can be pretty certain that the new behavior is 'correct'.

Both the new and old behavior are 'correct' to the letter of the
OpenStaep/MacOS-X documentation, but the new behavior is consistent
with the MacOS-X implementation, and seems to me to be more in line
with what I think they *meant* to say when they wrote the spec.

So yes, I think the RETAIN can be removed.

reply via email to

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