Re: NSDirectoryEnumerator memory problem
Re: NSDirectoryEnumerator memory problem
- Subject: Re: NSDirectoryEnumerator memory problem
- From: David Remahl <email@hidden>
- Date: Tue, 11 Feb 2003 12:43:27 +0100
Oh, and don't forget to increment i every time through the loop, like I
did! :-)
/ David
On Tuesday, February 11, 2003, at 12:35 PM, David Remahl wrote:
Use a local autorelease pool, like I show below (in your code example).
/ Rgds, David
On Tuesday, February 11, 2003, at 12:19 PM, TACKEL wrote:
Hi all,
I have a little application that searches in the whole HD for some
files but it gets more and more memory, so when it finishes the
search my equip is almost frozen.
The problem is the NSDirectoryEnumerator but I don't know how to
manage this issue.
Any idea?
NSFileManager *fmanager =[NSFileManager defaultManager];
NSDirectoryEnumerator *direnum = [fmanager enumeratorAtPath:@"/"];
NSString *entry;
NSAutoreleasePool *autoPool = [[NSAutoreleasePool alloc] init];
int i = 1;
while (entry = [direnum nextObject])
{
if( i % 100 ) // every hundredth pass through the loop, release the
local autorelease pool.
{
[autoPool release];
autoPool = [[NSAutoreleasePool alloc] init];
}
some file checks
i++;
}
[autoPool release];
Thanks,
Tackel
_______________________________________________
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.
_______________________________________________
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.
_______________________________________________
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.