draft proposal for ref counting in D
Walter Bright
newshound2 at digitalmars.com
Wed Oct 9 17:09:35 PDT 2013
Steven Schveighoffer wrote:
On Jun 25, 2013, at 9:31 PM, Michel Fortin wrote:
> Le 25-juin-2013 à 17:20, Steven Schveighoffer a écrit :
>
>> I don't think the autoreleasepool is relying on convention, it's simply
giving the compiler a way to elide careful tracking of temporaries' reference
counts.
>
> Not at all. Autorelease pools were useful at a time before ARC so you
wouldn't have to think of releasing manually every object called functions were
returned to you. Instead, most functions would return autoreleased object and
you'd only have to retain those objects you were storing elsewhere.
Having used MRC, I appreciate what autoreleasepool did, but I thought of it
being also as a kind of blanket way to allow the compiler to remove extra
retains/releases in ARC.
Is it not advantageous to release a whole pool of objects vs. releasing them
individually during execution? All releases and retains are atomic, so I
figured one could do some optimization when it's all lumped together.
I find the autorelease pools very GC-like -- you don't have to worry who uses or
forgets the reference, it's kept in memory until you don't need it.
Anyway, everything I know about Obj-C ARC I learned from my iOS 5 book :) So
don't take me as an expert.
-Steve
More information about the Digitalmars-d
mailing list