Blog post: Demystifying Garbage Collectors

Era Scarecrow rtcvb32 at yahoo.com
Sat Oct 13 12:18:09 PDT 2012


On Friday, 12 October 2012 at 19:19:23 UTC, Andrei Alexandrescu 
wrote:
> On 10/11/12 9:15 PM, Alex Rønne Petersen wrote:
>> http://xtzgzorex.wordpress.com/2012/10/11/demystifying-garbage-collectors/
>>
>> Essentially an explanation of garbage collection for the 
>> layman programmer. Though, it does assume some familiarity 
>> with C and memory management. It's an abstract article not 
>> particularly specific to any GC implementation, but I figured 
>> I'd post it here anyway in case anyone's interested.
>>
> http://www.reddit.com/r/programming/comments/11doh4/demystifying_garbage_collectors/

  A question comes up, and I don't need an answer but it may be 
useful to know, but I'm curious.

  Does D include an index to bitmaps specifying which offsets in a 
given memory block (say a class or a struct) of which fields 
actually would point to memory? With the strong possibility of 
working with manual pointer management it is possible it's not as 
useful as it could be; But may be considered when making a GC. 
Who knows, I may try my hand at it.

  //some pseudo random number generator class
  class Prng {
   int seed;
   int[] cached;

   //mem location as good as any for an initial seed,
   //maybe xor against time/date
   this() {seed = cast(int) &this;}
  }

  The above may have a bitmap indexed to 00000_010b (or an index 
so enum {nil, charArray, intArray} and thus [nil, intArray, nil], 
so it would skip the ints and only check the only that actually 
would contains a pointer. It could also effectively hold 
additional information on the type for further indexing, so when 
it sees 'cached' it will know it's an array, but if it was an 
array to Objects, then it would scan every part of that inner 
array mentioned for further references.


More information about the Digitalmars-d-announce mailing list