Re: Memory Leak with NSMutable String
Re: Memory Leak with NSMutable String
- Subject: Re: Memory Leak with NSMutable String
- From: "Alexander F. Hartner" <email@hidden>
- Date: Tue, 27 Jan 2004 12:19:01 +0200
Thanks guys for all your help. I do understand it much better now. The
documentation around NSAutoReleasePool was also very helpful. What I
did not understand (but do now) was that you can, and should, use
multiple NSAutoReleasePool instances, where needed. I was under the
FALSE impression that the release pool would get emptied automatically.
As I am using a FoundationTool the AutoReleasePool does not get release
periodically, which resulted in what I thought was a memory leak. From
what I have learned now, it was only the AutoReleasePool filling up
until it was being released in the application.
To address this I added another NSAutoReleasePool which I release
periodically and viola, No more excessive memory usage:
NSAutoreleasePool *subpool=[[NSAutoreleasePool alloc] init];;
for (counter=0; counter<1000000;counter++)
{
if (counter0000==0)
{
NSLog(@"CLEANUP");
[subpool release];
subpool=[[NSAutoreleasePool alloc] init];
}
doStuff();
}
[subpool release];
Thanks again
Alex
_______________________________________________
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.