Re: In-loop releasing of objects does not free memory?
Re: In-loop releasing of objects does not free memory?
- Subject: Re: In-loop releasing of objects does not free memory?
- From: j o a r <email@hidden>
- Date: Thu, 14 Feb 2008 20:36:22 -0800
On Feb 14, 2008, at 7:57 PM, Jim Correia wrote:
But -release is a no-op in GC code. NSAutoreleasePool will never get
the message. So we need a new message that we can send
NSAutoreleasePool that it will actually get when running in GC mode.
And for convenience, in non-GC mode it should do the same thing as -
release always did, to provide a single, simple idiom for inner
autorelease pools that will work in either GC or non-GC mode.
Yes, strictly speaking, it is inconsistent. But also necessary; the
alternatives would be uglier.
I don't know if I agree. Rather than repeatedly creating and
destroying a local autorelease pool in a non-GC app, why not instead
using "-drain" with the same type of semantics as in GC?
---------------------------------------------
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
for (id foo in foos)
{
// Stuff...
[pool drain];
}
[pool release];
---------------------------------------------
Much better IMO. The above would work fine in both GC and non-GC, and
it doesn't suffer from the completely unexpected behaviour of having
(drain == release) in non-GC.
Now, this is all a moot point of course... :-)
j o a r
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden