version(ctfe)

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Oct 19 08:33:46 PDT 2009


Leandro Lucarella wrote:
> Andrei Alexandrescu, el 19 de octubre a las 08:38 me escribiste:
>> For relatively large chunks of memory, the GC keeps a control block.
>> We could add a member size_t requestedSize that keeps the size that
>> was requested with an allocation/reallocation call. The GC can take
>> initiative in overallocating memory and expose primitives such as
>> requestedSize (how much did the program ask for?) and capacity (how
>> much is really allocated?).  With that API, it is possible to
>> implement ~= efficiently.
> 
> That would mean moving the overhead of arrays to the GC, but that overhead
> will be present for *all* objects, arrays or not, so I don't think it will
> be a good idea...

I forgot to mention that ~= would also have a means to communicate the 
GC to overallocate. My point is simple: the problem is that slices don't 
  store enough info. That info could get in the memory control block.

> Having that information could be used if present though, for example, to
> avoid scanning chunks of memory that are not used. That could help
> avoiding false positives (if that chunks of memory are not zeroed
> already).

Good point.


Andrei



More information about the Digitalmars-d mailing list