bug-gnustep
[Top][All Lists]
Advanced

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

Some small issues..


From: Ludovic Marcotte
Subject: Some small issues..
Date: Thu, 18 Oct 2001 10:05:18 -0400 (EDT)

Hi,

First of all, in Ink.app - Document.m: -makeWindow we have:

ASSIGN(tv, textView);

and it should be:

tv = textView;

Otherwise, the retain count of tv will always be >= 1.

I've also noticed a serious memory leak in NSTextView. If we take the code
of Ink.app for initializing the NSTextView, it looks like:

  textView = [[NSTextView alloc] initWithFrame: textRect];

  [textView setBackgroundColor: [NSColor whiteColor]];
  [textView setRichText: YES];
  [textView setUsesFontPanel: YES];
  [textView setDelegate: self];
  [textView setHorizontallyResizable: NO];
  [textView setVerticallyResizable: YES];
  [textView setMinSize: NSMakeSize (0, 0)];
  [textView setMaxSize: NSMakeSize (1E7, 1E7)];
  [textView setAutoresizingMask: NSViewHeightSizable |
                                 NSViewWidthSizable];
  [[textView textContainer] setContainerSize: NSMakeSize 
                                              (textRect.size.width,1e7)];
  [[textView textContainer] setWidthTracksTextView: YES];

After initializing the object, we expect textView to have a retainCount of
1. But no, it has a retainCount of 2. And as far I know, this is the
"correct way" of initializing a NSTextView.

The call:

  [[textView textContainer] setContainerSize: NSMakeSize
                            (textRect.size.width,1e7)];

makes the textView retainCount go from 1 to 2. It causes serious memory
leaks since NSTextView: -dealloc will never be called (since the textView
will always have a retainCount >= 1). So, lots of objects (NSTextStorage,
NSLayoutManager, NSTextContainer, ...) retained by the NSTextView
(actually, not all of them are) won't be released.

I've searched in the code and I'll probably find where that nasty bug
is.. but my eyes are hurting now :)

Anyone has an idea?

Ludo

-- 
Live as if you were to die tomorrow.
Learn as if you were to live forever.
 - Gandhi




reply via email to

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