Recursive Calls increase the memory
Recursive Calls increase the memory
- Subject: Recursive Calls increase the memory
- From: Lorenzo Puleo <email@hidden>
- Date: Tue, 04 Jun 2002 20:41:56 +0200
Hi,
I call recursively a routine, and my application memory grows in infinite
way. I saw this with the tool "ProcessViewer".
I think that, at least at the end of the task, the memory should come back
at the initial value, but this is not true.
Sometimes it starts from 5MB and ends with 80MB...!
I have a NSMutableArray RETAINED instance "gItemsToCopyArray".
Then I get the first item:
NSDictionary *itemToCopy = [gItemsToCopyArray objectAtIndex:0];
This dictionary contains an array of items. I launch my routine this way.
[self CopyItems:[itemToCopy objectForKey:@"subItems"]];
- (void)CopyItems:(NSArray*)theArray
{
int i, totItems, copyMode;
NSDictionary *taskDict;
NSString *source, *dest;
NSArray *subItems;
BOOL ok = YES;
totItems = [theArray count];
for(i = 0; i < totItems; i++){
taskDict = [theArray objectAtIndex:i];
source = [taskDict objectForKey:@"source"];
dest = [taskDict objectForKey:@"dest"];
gGlobalItemsToDo--;
// just to isolate the trouble
// I commented the following line. The trouble persists.
//[self CopySource:source toDest:dest copyMode:copyMode];
subItems = [taskDict objectForKey:@"subItems"];
if(subItems != nil){ // it's a folder
[self CopyItems:subItems];
subItems = nil;
}
taskDict = nil;
source = nil;
dest = nil;
}
}
And the application memory grows at any recursive call.
Since "gItemsToCopyArray" is a retained instance, may be is this the cause
of the infinite increasing memory?
How should I have to fix this?
Any assistance would be greatly appreciated. Thank you.
--
Lorenzo Puleo
mailto:email@hidden
_______________________________________________
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.