bugGNUstep - Bugs: bug #13705, possible memory leak in...

Group
 
 

bug #13705: possible memory leak in setStringValue

Submitter:  Riccardo Mottola <rmottola>
Submitted:  Sun 10 Jul 2005 12:41:31 AM UTC
   
 
Category:  Gui/AppKit Severity:  3 - Normal
Item Group:  Bug Status:  Fixed
Privacy:  Public Assigned to:  FredKiefer
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 30 May 2006 12:43:30 PM UTC, comment #7: 

Tested on Solaris 10 x86
    No more memory leaks
Tested on Solaris 9 sparc
    No more momory leaks

UBoss <uboss>
Mon 29 May 2006 10:33:12 PM UTC, comment #6: 

Thank you for the hints you did send in a separate mail. Yes, you are right the XFT  structures should be freed on dealloc. I added code for this and a little bit more.
Could you please retest if the memory leak is now fixed for you, or if there is another leak.

Fred Kiefer <FredKiefer>
Group Member
Sat 27 May 2006 10:41:17 PM UTC, comment #5: 

Could not reproduce this problem with the xlib backend on Suse 10.1 linux. (But had other problems with that backend here)
I would think that this problem is specific to solaris. Could you please use valgrind (or a similar tool) to find out, where the memory gets leaked?

Fred Kiefer <FredKiefer>
Group Member
Tue 16 May 2006 01:16:15 PM UTC, comment #4: 

oh i forgot

runnign on sun blade 1500 sparc solaris 8(9)

UBoss <uboss>
Tue 16 May 2006 01:13:58 PM UTC, comment #3: 

It realy looks like memory leak in text rendering fro me the memory increase stops when PSshow(timeStr); lines are commented
but happens only on gnustep-back-0.10.2 on back-0.9.0 works fine no increase of used memory.

using x11-xlib backend as library (--disable-backend-bundle)
....
    //-----------------------------------------------
    strftime (timeStr, 12, "%H:%M:%S", gmtime (&currentTime));
    [clockFont set];
    PSsetrgbcolor (.0, .85, .0);
    PSmoveto (NSMinX(tmpR)+ 42., NSMinY(tmpR)+ NSHeight(tmpR) - 18.);
    PSshow (timeStr);
    //-----------------------------------------------
    strftime (timeStr, 12, "%d.%m", gmtime (&currentTime));
    [dateFont set];
    PSsetrgbcolor (.0, .6, .0);
    PSmoveto (NSMinX(tmpR)+ 4., NSMinY(tmpR)+ NSHeight(tmpR) - 18.);
    PSshow (timeStr);
    //-----------------------------------------------
....

also memorz increase happend in gnustep=examples GSTest NSTableView test when resize tableview and then moving with scrollabr to force redraw of it's content.


UBoss <uboss>
Sun 10 Jul 2005 09:07:18 AM UTC, comment #2: 

As this looks like an important problem I tried hard to reproduce it with a simple program, but failed to.
A small loop made up of the lines you posted does not produce a memory leak:

int main (int argc, const char *argv[])
{
  int i;
  NSString *speedStr;
  NSTextField         *infoSpeed;
  CREATE_AUTORELEASE_POOL(pool);

  [NSApplication sharedApplication];
  infoSpeed = [[NSTextField alloc] init];

  for (i = 0; i < 1000000; i++)
    {
      speedStr = [NSString alloc];
      speedStr = [speedStr initWithFormat:@"%3.2fB/s", i * 0.1234];
      [infoSpeed setStringValue:speedStr];
      [speedStr release];
    }

  RELEASE(pool);
  return 0;
}

Are you using a formatter for the text field?
It may also be that the leak is in the text rendering mechanism which doesn't get used by my code.

Fred Kiefer <FredKiefer>
Group Member
Sun 10 Jul 2005 12:59:44 AM UTC, comment #1: 

just as a note

using
[NSString stringWithFormat: xxx]

instead of alloc+init does the same thing and no changes.


Riccardo Mottola <rmottola>
Group Member
Sun 10 Jul 2005 12:41:31 AM UTC, original submission:  

I found a possible memory leak in setStringValue.
Hunting down some excessive memory usage during file transfers in FTP.app (of GAP project), I noticed that while on MacOSX the memory goes up and up during a transfer but returns to the original value afte rthe transfer finished, on GNUstep the usage remains high. Transferring another file makes memory usage increase further.

Essentially the core is:

speedStr = [NSString alloc];
        speedStr = [speedStr initWithFormat:@"%3.2fB/s", speed];
    [infoSpeed setStringValue:speedStr];
    [speedStr release];

now by commenting in and out code lines, I found that if the setStringValue call is not done, memory usage doesn't increase inside the download loop.
It wonders me that such a call is memory expensive, but still, on osx the memory is freed, on gnustep not and it leask as wild, thus I fear a bug like a missing release.

I forgot,
    IBOutlet NSTextField         *infoSpeed;

Reproduceable on netbsd and linux.

maybe it is not possible to call setStringValue repeatedly for  a text filed? would be strange....

Riccardo Mottola <rmottola>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

Follow 4 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2006-05-30 FredKiefer Open/ClosedIn Test Closed
2006-05-29 FredKiefer StatusNone Fixed
    Assigned toNone FredKiefer
    Open/ClosedOpen In Test

Back to the top

Powered by Savane 3.13-cf05.
Corresponding source code