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: glenn andreas <email@hidden>
- Date: Fri, 15 Feb 2008 09:28:39 -0600
On Feb 15, 2008, at 7:41 AM, Jim Correia wrote:
On Feb 14, 2008, at 11:36 PM, j o a r wrote:
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?
Well, I was trying to provide a plausible explanation for why we
ended up with -drain as a synonym for -release, not second guess the
decision with the advantage of hindsight (and the disadvantage of
not having all the facts before me.).
I remember the WWDC that was just after "drain" appeared in the
headers, there was a comment to the effect that "yeah, we're going to
work on GC, and that's what 'drain' is going to be used for, but in
the mean time, don't use it because it really doesn't work like you'd
expect it to".
My memory colored this as "drain was not suppose to be synonymous with
release, but that's how it ended up - sorry". This, of course,
neither confirms nor conflicts with the explanation ("release is a nop
so we needed a special pseudo-release"), though the "Special
Considerations" section of the documentation for -drain is consistent
with that.
And lets face it - creating and destroying an auto-release pool isn't
that much more work/code/processor time than using a -drain call that
works like you'd expect it to on non-GC...
Perhaps filing a bug requesting a "-removeAllObjects" method be added
to NSAutoreleasePool which is -drain under GC and is not -release
under non-GC?
Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next
generation of fractal art
_______________________________________________
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