Re: Never ending lack of memory
Re: Never ending lack of memory
- Subject: Re: Never ending lack of memory
- From: Stéphane Sudre <email@hidden>
- Date: Mon, 10 Mar 2003 12:01:40 +0100
On Monday, March 10, 2003, at 11:43 AM, Dietrich Epp wrote:
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];
And it would still not deallocate the dirContent array. And if you put
the NSAutoReleasePool outside of the loop, you've improved the
situation but there's still a lot of objets waiting for releasing.
NSAutoReleasePool* aPool;
_______________________________________________
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.