• 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: Never ending lack of memory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Never ending lack of memory


  • Subject: Re: Never ending lack of memory
  • From: email@hidden
  • Date: Sat, 8 Mar 2003 20:22:58 +0100

On samedi, mars 8, 2003, at 07:53 PM, Lorenzo Puleo wrote:

I call the following recursive routine
[self ScanSingleFolder:@"/"]; (see below)

and the Terminal top command reports and increasing RSize of 80, 90,...
400...MB. My application grows 4MB each second. I get I lot of pageins and
pageouts, and up above, even if I stop the task, I have to wait long time to
free up the CPU again, and last, this amount of RSize never decreases.
Where did I do wrong?


- (BOOL)ScanSingleFolder:(NSString*)sourceDir
{
int i;
NSMutableString *subItem = [NSMutableString string];
BOOL isDir;
NSArray *dirContent = [manager
directoryContentsAtPath:sourceDir];

for(i = 0; i < [dirContent count]; i++){
if(isCopying == NO) break;
[subItem setString:[sourceDir
stringByAppendingPathComponent:[dirContent objectAtIndex:i]]];
[manager fileExistsAtPath:subItem isDirectory:&isDir];
if(isDir) [self ScanSingleFolder2:subItem];
}
return YES;
}

Thank you for your (hopefully) help.

1) Why don't you use the BSD routines or the FSRef ones dedicated to scanning directories?

2) Since you're not releasing any string before the end of the scan, it's not very surprising that the memory is growing a lot.

To give you an idea of the amount of data not released before the end of the scan, I put a NR on the problematic lines:

- (BOOL)ScanSingleFolder:(NSString*)sourceDir
{
int i;
NR NSMutableString *subItem = [NSMutableString string];
BOOL isDir;
NR NSArray *dirContent = [manager
directoryContentsAtPath:sourceDir];

for(i = 0; i < [dirContent count]; i++){
if(isCopying == NO) break;
NR [subItem setString:[sourceDir
stringByAppendingPathComponent:[dirContent objectAtIndex:i]]];
[manager fileExistsAtPath:subItem isDirectory:&isDir];
if(isDir) [self ScanSingleFolder2:subItem];
}
return YES;
}

Maybe this can be avoided using this kind of folder scanning:

- (BOOL)ScanSingleFolder:(NSString*)sourceDir
{
NSDirectoryEnumerator * tEnumerator;
NSString * subItem;

tEnumerator= [manager enumeratorAtPath: sourceDir];

while ((subItem =[tEnumerator nextObject])!=nil)
{
...
}
}
_______________________________________________
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: Never ending lack of memory
      • From: Lorenzo Puleo <email@hidden>
    • Re: Never ending lack of memory
      • From: Jesus De Meyer <email@hidden>
References: 
 >Never ending lack of memory (From: Lorenzo Puleo <email@hidden>)

  • Prev by Date: Re: Cocoa friendly Quicktime APIs?
  • Next by Date: Re: Never ending lack of memory
  • Previous by thread: Never ending lack of memory
  • Next by thread: Re: Never ending lack of memory
  • Index(es):
    • Date
    • Thread