draft proposal for ref counting in D
Walter Bright
newshound2 at digitalmars.com
Wed Oct 9 17:10:08 PDT 2013
Michel Fortin wrote:
Le 25-juin-2013 à 21:40, Steven Schveighoffer a écrit :
> On Jun 25, 2013, at 9:31 PM, Michel Fortin wrote:
>
>> 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 haven't done any benchmarking, but I'd have to assume it is more advantageous
to just return objects retained since Apple went to great lengths to make sure
this can happen even when the convention is to return autoreleased.
There's no question it also simplifies the compiler. It's much easier to reason
about pairs of retain/release than retain/autorelease.
> 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.
The concept was truly great, no doubt about that.
More information about the Digitalmars-d
mailing list