Memory management design
Michel Fortin
michel.fortin at michelf.ca
Wed Jul 10 04:21:36 PDT 2013
On 2013-07-10 08:00:42 +0000, Manu <turkeyman at gmail.com> said:
> I'd push for an ARC implementation. I've become convinced that's what I
> actually want, and that GC will never completely satisfy my requirements.
There's two ways to implement ARC. You can implement it instead of the
GC, but things with cycles in them will leak. You can implement it as a
supplement to the GC, where the GC is used to collect cycles which ARC
cannot release. Or you can implement it only for a subset of the
language by having a base reference-counted class and things derived
from it are reference counted.
The two first ideas, which implement ARC globally, would have to call a
function at each and every pointer assignment. Implementing this would
require a different codegen from standard D, and libraries compiled
with and without those calls on pointer assignment would be
incompatible with each other.
On the other end, having a reference counted base class is of more
limited utility because you can't reuse D code that rely on the GC if
your requirement does not allow the GC to run when it needs too. But it
does not create codegen fragmentation.
--
Michel Fortin
michel.fortin at michelf.ca
http://michelf.ca
More information about the Digitalmars-d
mailing list