Manual memory management in D2
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Jul 13 13:19:52 PDT 2010
On 07/13/2010 02:42 PM, bearophile wrote:
> Andrei Alexandrescu:
>> But manual deletion has no business in the garbage collected
>> heap. That currently druntime provides it is an accident caused by the
>> current implementation; most GC's cannot provide efficient manual
>> reclamation. And they shouldn't anyway.
>
> The structure of memory blocks is like a graph, generally each memory zone can have inbound references and outbound ones.
> In unsafe D if I am "sure" a GC-managed memory zone (like a large array of doubles or a large associative array from int to double) has no inbound references, then I want a way to deallocate it quickly.
> In SafeD that can't be allowed, because if I am wrong that operation can generate some broken references.
> So in SafeD the delete operation can be replaced by something safer, a way to tell the GC to deallocate just a specific object, walking the graph and setting to null all the inbound pointers (this is a slower operation).
> A problem is that the GC is conservative, so some of those references can be something different, and setting them to null can damage the program state. So it seems even less safe.
The problem is that many of today's GC are structured in ways that make
efficient reclamation of individual block extremely inefficient.
Andrei
More information about the Digitalmars-d
mailing list