Big grinding memory leak?
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.