Out of memory error (even when using destroy())

nkm1 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 27 12:38:39 PDT 2017


On Saturday, 27 May 2017 at 17:57:03 UTC, Mike B Johnson wrote:

> And what if one isn't interfacing to C? All pointers should be 
> known.

Apparently some people are (were?) working on semi-precise GC: 
https://github.com/dlang/druntime/pull/1603
That still scans the stack conservatively, though.

> Therefor, in a true D program(no outsourcing) with no pointers 
> used, the GC should never have to scan anything.
All realistic programs (in any language) use a lot of pointers - 
for example, all slices in D have embedded pointers (slice.ptr), 
references are pointers, classes are references, etc.

> It seems the GC can be smarter than it is instead of just 
> making blanket assumptions about the entire program(which 
> rarely hold), which is generally always a poor choice when it 
> comes to performance...
If you only have compile time information, making blanket 
assumptions is inevitable - after all, compiler can't understand 
how a nontrivial program actually works. The alternative is doing 
more work at runtime (marking pointers that changed since 
previous collection, etc), which is also not good for performance.

> Who knows, some pointer externally might be peeping in on our 
> hello world program.
Of course, there is a pointer :)

void main()
{
     import std.stdio;

     writeln("hello world".ptr);
}


More information about the Digitalmars-d-learn mailing list