Re: [newbie] NSString code so it won't leak
Re: [newbie] NSString code so it won't leak
- Subject: Re: [newbie] NSString code so it won't leak
- From: Chris Ross <email@hidden>
- Date: Wed, 11 Sep 2002 10:32:31 +0100
On Wednesday, September 11, 2002, at 05:26 am, Charles Srstka wrote:
On Tuesday, September 10, 2002, at 10:44 PM, Dean Davis wrote:
[snip]
What the hell?! I looked at the code, and it *should* crash. If it's
not (and if the other one was leaking), then the autorelease pool
isn't getting released, and that's really bizarre and should probably
be reported as a bug.
However, if you enclose your code in these two lines:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// your code here
[pool release];
What happens to objects that are not ready to be released ?
Do they get given to the parent pool ?
Can I do this in the main loop of a thread to make sure memory
free'd up correctly whilst still retaining the objects I wish to keep?
By that I mean:
NSAutorealePool *pool = nil;
for( i = 0; i < SomeNumber; i++ )
{
pool = [[NSAutoreleasePool alloc] init];
..... main processing of the loop ....
[pool release];
}
If not, is there anyway to flush the pool so that objects do not build
up?
Regards,
Chris
--
Chris Ross - email@hidden -
http://www.darkrock.co.uk
Ferite Programming Language -
http://www.ferite.org
_______________________________________________
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.