Rust moving away from GC into reference counting

Rob T alanb at ucora.com
Mon Jun 3 09:47:34 PDT 2013


On Monday, 3 June 2013 at 16:01:29 UTC, H. S. Teoh wrote:

C++11 deprecated auto_ptr in favor of unique_ptr, but it's 
basically the same concept, and it works very well in cases where 
you prefer to manage your own memory. D should have the same 
thing in the std lib, it's not difficult to implement. The ref 
counted pointers are another similar thing, a bit more difficult 
to implement correctly and there's a circular ref issue with them.

The "hierarchy of memory management schemes" is something we 
should embrace instead of shun in favor of the GC. I dislike 
being forced to use the GC, or having to jump through hoops to 
avoid it, and it's insane to have no control over it even when I 
really do want to make use out of it.

The GC can of course be made a lot better, and at least some 
important manual  control can be given to the programmer, for 
example we previously discussed ideas like specifying a maximum 
time limit for each GC run, and also specifying when the GC gets 
called. Currently we have virtually zero contol over the GC 
(other than enable and disable which is far too trivial) but I 
see no reason at all why this must be the case. Allowing some 
significant control over the GC should be independent of the GC 
implementation, so having a better GC design should in no way 
reduce or remove the requirement for having control.

Also a better GC in no way invalidates the need for other memory 
management schemes because there will always be situations where 
a GC is not an appropriate solution, at least not until someone 
invents the perfect one size fits all GC.

--rt


More information about the Digitalmars-d mailing list