draft proposal for ref counting in D

Walter Bright newshound2 at digitalmars.com
Wed Oct 9 17:05:08 PDT 2013


On Jun 25, 2013, at 5:28 PM, Walter Bright wrote:

 > If autoreleasepull is just a handy way to lump together Release() calls, then 
that is quite unnecessary if the compiler inserts calls to Release() 
automatically. If it is, instead, a promise that members of autoreleasepull do 
not leak references outside of that object, then this is very problematic for D 
to guarantee such - and guarantee it it must. I.e. it's "escape analysis" in 
another disguise.
 >
 > I think the compiler should pick where to put the Release() calls, that is 
the whole point of ARC. If the compiler can do sufficient escape analysis to 
determine that the calls can be elided, so much the better.

I'm not sure exactly what is required for ARC to guarantee proper memory 
management (whether it requires flow-analysis or not), but it seems to work 
quite well for Objective-C. I think it helps minimize the expensive 
release/retain calls when you can just say "oh, someone else will clean that up 
later", just like you can with a GC.

It might be good for someone who knows the ARC eliding techniques that clang 
uses to explain how they work.  We certainly shouldn't ignore those techniques.

-Steve


More information about the Digitalmars-d mailing list