• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Big grinding memory leak?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Big grinding memory leak?


  • Subject: Big grinding memory leak?
  • From: Martin Häcker <email@hidden>
  • Date: Sun, 27 Apr 2003 22:44:57 +0200

Hi there,

today I just tried a little helper app that enumerates over all the files of the current directory and tells me which of the pictures within are below 1024*768.

Well, that seems to work, but I have the big problem that every time I use this my memory usage absolutely skyrockets and has already brought down my system once (partly because the stupid implementation of NSUserDefaults thinks it's fun to throw away all its preferences if the disk is too full to save a new copy).

Well... as far as I understands this there should be no immediate problem with this implementation as all the objects in it will either be very small (the autoreleased strings) or get a release immediately meaning that they should be destroyed.

Right?

--- snip ---
#import <Cocoa/Cocoa.h>

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

id basePath = [[NSFileManager defaultManager] currentDirectoryPath];
id direcotryIterator = [[NSFileManager defaultManager] enumeratorAtPath:basePath];
id currentFile;
NSSize size;

while (currentFile = [direcotryIterator nextObject]) {
size = NSMakeSize(0, 0);
id currentImage = [[NSImage alloc] initWithContentsOfFile:currentFile];
if (currentImage) { // may be nill if currentFile is not an image
size = [currentImage size];
if (size.width < 1024 || size.height < 768) {
// fixme: something better?
printf("%s\n", [currentFile cString]);
}
[currentImage release];
}
}
[pool release];
return 0;
}

--- snap ---
I must clearly be overlooking something pretty simple here, but I can't see it.

Thanks in advance for any help,

cu Martin
--
dont.wanna.tell
[ot]coder - hehe
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Big grinding memory leak?
      • From: David Remahl <email@hidden>
References: 
 >Re: Hiding an NSTextField (From: Theodore Petrosky <email@hidden>)

  • Prev by Date: Re: Getting window locations for other applications
  • Next by Date: Re: Big grinding memory leak?
  • Previous by thread: Re: Hiding an NSTextField
  • Next by thread: Re: Big grinding memory leak?
  • Index(es):
    • Date
    • Thread