• 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: Dietrich Epp <email@hidden>
  • Date: Mon, 10 Mar 2003 02:43:40 -0800

On Saturday, Mar 8, 2003, at 10:53 US/Pacific, 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?

Here's how you take care of autorelease'd things in loops. Don't worry about switching stringBy-- to alloc/init because if your code leaks like a seive [as it does] you don't want to patch leaks one by one if you don't have do [as you don't]. Also, autorelease is safer.

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

NSAutoReleasePool* aPool;


for(i = 0; i < [dirContent count]; i++){
if(isCopying == NO) break;

aPool = [[NSAutoReleasePool alloc] init];

[subItem setString:[sourceDir
stringByAppendingPathComponent:[dirContent objectAtIndex:i]]];
[manager fileExistsAtPath:subItem isDirectory:&isDir];

[aPool release];

if(isDir) [self ScanSingleFolder2:subItem];
}
return YES;
}
_______________________________________________
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: Dietrich Epp <email@hidden>
    • Re: Never ending lack of memory
      • From: Stéphane Sudre <email@hidden>
References: 
 >Never ending lack of memory (From: Lorenzo Puleo <email@hidden>)

  • Prev by Date: Re: Need guidance in table sorting
  • Next by Date: Application with documents
  • Previous by thread: Re: Never ending lack of memory
  • Next by thread: Re: Never ending lack of memory
  • Index(es):
    • Date
    • Thread