How Garbage Collector works?

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Thu Aug 12 02:05:54 PDT 2010


On Thu, 12 Aug 2010 10:44:51 +0200, Borneq wrote:

> Użytkownik "Nick Sabalausky" <a at a.a> napisał w wiadomości
> news:i40b9m$1ti5$1 at digitalmars.com...
>> The GC keeps track of the starting address and the length of each
>> allocation.
> 
> How to deal with:
> 1.alloc 1000 bytes to pointer
> 2.increment pointer by 500 bytes
> 3.checking if block 1000 bytes is reachable but only pointer is in roots

Since the GC keeps track of the length of the memory block, it can also 
tell whether the pointer is inside the memory block.

  if (pointer >= startOfBlock && pointer < startOfBlock + blockLength)
      doNotCollect();

-Lars


More information about the Digitalmars-d mailing list