discuss-gnustep
[Top][All Lists]
Advanced

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

NSAutoreleasePool does not free all memory


From: Gerald Siebke
Subject: NSAutoreleasePool does not free all memory
Date: Sun, 29 Apr 2001 22:39:01 +0200 (CEST)

Hi,

I have installed the latest cvs-version on NetBSD 1.5_ALPHA
with the default egcs-1.1.2.

I have the following problem with an NSAutoreleasePool:

The allocated memory inside the NSAutoreleasePool is not completely
freed outside.

CASE #1
-------
line '16' contains : autorelease

before allocation                                       : 4.9 MB
after allocation                                        : 7.8 MB
after destroy  NSAutoreleasePool        : 7.0 MB        <-- why ???


CASE #2
-------
we changed in line '16' : autorelease --> release

before allocation                                       : 4.9 MB
after allocation                                        : 7.5 MB
after destroy  NSAutoreleasePool        : 4.9 MB        <-- this is okay !


This the small code :
---------------------

#import <Foundation/Foundation.h>

int main (int argc, const char *argv[])
{
    NSLog(@"check memory before allocating");
    sleep(5);
    {
        NSAutoreleasePool       *pool = [NSAutoreleasePool new];
        int                                     i;
                NSString                        *newString;
                NSMutableArray          *myArray = [NSMutableArray array];

        for (i=0 ; i<50000; i++) {
                        newString = [NSString new];
                        [myArray addObject:newString];
                        [newString autorelease];        // [newString release]; 
<-- works
                }

                NSLog(@"check memory after allocating");
        sleep(5);

        [pool release]; pool = nil;
    }

    NSLog(@"Autoreleasepool released, check memory");
    sleep(15);

    exit(0);
}

---------


The same happens with other classes, too.

Is it a bug in core/base ?
Who has any ideas ?


Thanks,
Gerald

   _  _
 _(_)(_)_  Gerald Siebke, Software Developer, Turbocat's Development,
(_) __ (_) Buchhorster Strasse 23, D-16567 Muehlenbeck/Berlin, FRG,
  _/  \_   Fax +49 33056 82835 Mail gerald@turbocat.de
 (______)  ¬http://www.turbocat.de/
           DEVELOPMENT * CONSULTING * ADMINISTRATION




reply via email to

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