discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Memory leaks?


From: Richard Frith-Macdonald
Subject: Re: Memory leaks?
Date: Mon, 05 Sep 2005 13:47:08 +0100

On 2005-09-05 13:11:18 +0100 Chris Vetter <cbv@gmx.net> wrote:

Hi there,

while testing and playing around with instance counting, I found that a
simple

  void main(void)
  {
    NSAutoreleasePool *pool = nil;

    pool = [[NSAutoreleasePool alloc] init];
    {
      NSObject *o;

      o = [[NSObject alloc] init];
      NSLog(@"--> %@", [o description]);
      [o release];
    }
    [pool release];

    exit(EXIT_SUCCESS);
  }

gives me a total of 50 instances not accounted for:

../shared_obj/example: Memory leak detected: NSBundle (2), NSRecursiveLock
(2), NSUserDefaults (1), GSArrayEnumerator (35), NSLock (1),
GSArrayEnumeratorReverse (1), GSLazyRecursiveLock (3), NSFileManager (1),
GSNonretainedObjectValue (4)

Removing the NSLog(), I get no leak.
Shouldn't the autorelease pool take care of those instances?

No ... lots of objects are created and then cached for the lifetime of the process in case they need to be re-used (bundles, locks, user defaults, file manager, timezone, charactersets, various strings used as dictionary keys etc).

The array enumerators are puzzling though .... I wouldn't expect to see those after the autorelease pool is destroyed, and I don't see them when I run the example program above.





reply via email to

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