Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: In-loop releasing of objects does not free memory?




On Feb 15, 2008, at 8:27 AM, Adam P Jenkins wrote:

I still don't understand. Why does it matter that the release message to a NSAutoreleasePool would be a noop when running in GC mode? Isn't autorelease also a noop? In which case the whole NSAutoreleasePool is just a noop, since nothing would ever actually get added to it. So I still don't understand the need for the drain method as it's currently defined. Why couldn't you just send release to the pool in both GC and non-GC apps? I'm not saying what you said is wrong, I'm sure it's me that's missing something. Thanks,


Local autorelease pools are typically an optimization that we use when we know that we're going to generate a whole lot of temporary objects in a very short period of time, to keep the over all footprint of the application down. This improves the performance of your application, but also of the system as a whole.

The same type of problem exists in GC apps of course, and while the collector might - and in a perfect world should - be smart enough to notice that you're generating temporary objects very quickly and to determine that it needs to respond to that, it might also be that it could benefit from a hint from the developer about this in much the same way, and in the same type of situations, as where you would use a local autorelease pool in non-GC.

There is API for providing such a hint in a GC app (- [NSGarbageCollector collectIfNeeded]), but in code that runs in both GC and non-GC it might be convenient to not have to use both types of syntax and I think that's why "-drain" was introduced.

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >In-loop releasing of objects does not free memory? (From: Arthur C. <email@hidden>)
 >Re: In-loop releasing of objects does not free memory? (From: John Terranova <email@hidden>)
 >Re: In-loop releasing of objects does not free memory? (From: John Stiles <email@hidden>)
 >RE: In-loop releasing of objects does not free memory? (From: Arthur C. <email@hidden>)
 >Re: In-loop releasing of objects does not free memory? (From: Randall Meadows <email@hidden>)
 >Re: In-loop releasing of objects does not free memory? (From: Uli Kusterer <email@hidden>)
 >Re: In-loop releasing of objects does not free memory? (From: Nick Zitzmann <email@hidden>)
 >Re: In-loop releasing of objects does not free memory? (From: Randall Meadows <email@hidden>)
 >Re: In-loop releasing of objects does not free memory? (From: Michael Watson <email@hidden>)
 >Re: In-loop releasing of objects does not free memory? (From: Keith Duncan <email@hidden>)
 >Re: In-loop releasing of objects does not free memory? (From: Jim Correia <email@hidden>)
 >Re: In-loop releasing of objects does not free memory? (From: Adam P Jenkins <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.