• 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: Sun, 9 Mar 2003 13:45:15 +0100

On dimanche, mars 9, 2003, at 12:15 PM, Lorenzo Puleo wrote:

Ok,
I understand, the memory is not released.
So I try to *alloc* and *init* NSString and NSArray and release them at the
end of each recursion by myself (see below).

Itried this but it didn't work. When NSLog appears coming out from the dir,
say "/Applications", the memory is still the same, and it is still
increasing. Instead it should be like the moment I launched this method the
first time. Sorry, it doesn't work.
I miss some important step of the memory theory.


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

This is still creating an autoreleased array since the autoreleased array is created by [manager directoryContentsAtPath:sourceDir]. You can't prevent this.

for(i = 0; i < [dirContent count]; i++){
[subItem setString:[sourceDir
stringByAppendingPathComponent:[dirContent objectAtIndex:i]]];
[manager fileExistsAtPath:subItem isDirectory:&isDir];

Same problem with stringByAppendingPathComponent which is also creating an autoreleased string.

if(isDir){
[self ScanSingleFolder:subItem];
if([sourceDir isEqualToString:@"/"]
NSLog(@"Came out from: %@", subItem);
}
}
[dirContent release];
[subItem release];
return YES;
}



Ans last:
why does the following call, crash after 508 recursion?

- (BOOL)ScanSingleFolder:(NSString*)sourceDir
{
[self ScanSingleFolder:@"/"];
return YES;
}

Because you're doing something similar to the address of the Apple Campus.
_______________________________________________
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>
References: 
 >Re: Never ending lack of memory (From: Lorenzo Puleo <email@hidden>)

  • Prev by Date: Re: Georg looks at that Georg! ;-)
  • Next by Date: Re: Audio CD Naming
  • Previous by thread: Re: Never ending lack of memory
  • Next by thread: Re: Never ending lack of memory
  • Index(es):
    • Date
    • Thread