Re: Never ending lack of memory
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.