• 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
Re: NSDirectoryEnumerator memory problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSDirectoryEnumerator memory problem
      • From: Steve Bird <email@hidden>
References: 
 >Re: NSDirectoryEnumerator memory problem (From: David Remahl <email@hidden>)

  • Prev by Date: Re: NSDirectoryEnumerator memory problem
  • Next by Date: Re: Communication with StartupItem
  • Previous by thread: Re: NSDirectoryEnumerator memory problem
  • Next by thread: Re: NSDirectoryEnumerator memory problem
  • Index(es):
    • Date
    • Thread