More radical ideas about gc and reference counting

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Mon May 12 10:52:20 PDT 2014


On 5/12/2014 7:46 AM, Steven Schveighoffer wrote:
> It doesn't matter where the false pointers are. The largest issue with false
> pointers is not how many false pointers there are. It only matters how large the
> block is that it "points" at. The larger your blocks get, the more likely they
> are "pointed" at by the stack. On 32-bit systems, allocate 1/256th of your
> memory space (i.e. 16.5MB), and the likelihood of random data on the stack
> pointing at it is roughly 1/256. This problem is just about eliminated with
> 64-bit pointers.

Generally, it is a bad idea to allocate such large blocks on the GC heap. GC's 
work best when the size of the objects being allocated is very small relative to 
the size of the heap space.

Fortunately, it's a mathematical inevitability that large allocations relative 
to the GC size are rare, and so it isn't much of a pain to handle them manually.


> And in fact, even if it's forbidden, "requires" is too strong a word -- there is
> no static or runtime prevention of this.

It's still forbidden. Andrei wrote a template that will verify this at runtime, 
but I don't recall its name.



More information about the Digitalmars-d mailing list