[cfe-dev] NSAutoreleasePool checker

David Chisnall csdavec at swan.ac.uk
Fri May 27 13:16:50 PDT 2011


On 27 May 2011, at 20:47, Ted Kremenek wrote:

> On May 27, 2011, at 12:28 PM, Sean McBride wrote:
> 
>>> Does anyone object if I enable it unconditionally? 
>>> Sending -drain instead of -release to autorelease pools works in both GC
>>> and non-GC mode, while sending -release is a no-op in GC mode, so it's
>>> good style to use -drain always (recent Apple examples use -drain even
>>> in non-GC mode).
>> 
>> And drain works back to 10.4 even.  Personally, I'd like to see this change.
> 
> I think it is fine to worth considering this change because it "makes sense for all users."  If this is in the recommended Cocoa API practices, for example, I'd be more than happy to make this change.  If this makes sense for (say) all GNUStep users, and we can determine that we are using GNUStep, then I'd be fine with turning it on in that case as well because that would make sense for that platform (as decided by those project owners).

This has been the recommended practice for Cocoa since 10.5.  -drain will trigger a collection in GC mode and is equivalent to -release in non-GC mode.  Calling -release on an autorelease pool is, as I said in my first mail, bad style in any mode.

David





More information about the cfe-dev mailing list