DIP60: @nogc attribute

Byron via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 18 09:24:00 PDT 2014


On Fri, 18 Apr 2014 16:17:10 +0000, Brad Anderson wrote:
> 
> You can actually prevent scanning/collection already without much
> difficulty:
> 
> GC.disable();
> scope(exit) GC.enable();
> 
> I feel like @nogc is most useful in avoiding surprises by declaring your
> assumptions. Problems like how toUpperInPlace would still allocate (with
> gusto) could much more easily be recognized and fixed with @nogc
> available.


I am talking more about hinting to the conservative GC about blocks it 
doesn't need to scan for addresses.

struct Vertex { int x, y, z, w; }

@nogcscan
Vertex vertexs[10_000];

so when a GC scan does happen it can skip scanning the vertexs memory 
block completely since we are promising not to hold on to addresses in it. 


More information about the Digitalmars-d mailing list