Re: NSDirectoryEnumerator memory problem
Re: NSDirectoryEnumerator memory problem
- Subject: Re: NSDirectoryEnumerator memory problem
- From: Steve Bird <email@hidden>
- Date: Tue, 11 Feb 2003 07:12:11 -0500
On Tuesday, February 11, 2003, at 06:43 AM, David Remahl wrote:
How about testing for zero, instead of non-zero?
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.
if( (i % 100) == 0 ) // 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.
----------------------------------------------------------------
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
www.Culverson.com (toll free) 1-877-676-8175
_______________________________________________
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.