On Fri, 02 May 2014 13:26:41 -0400, Steven Schveighoffer <[email protected]> wrote:

Why not keep the 3 states, but just treat unmarked blocks as free? Then the next time you go through tracing, change the bit to free if it was already marked.

Sorry, if it was already *unmarked* (or marked as garbage).

essentially:

enum GCState {free, allocated, garbage}

GCState memoryBlocks[];

fullCollect()
{
   foreach(ref st; memoryBlocks)
   {
      final switch(st)
      {
      case GCState.free:
         break;
      case GCState.allocated:
         st = GCState.garbage;
         break;
      case GCState.garbage:
         st = GCState.free;
         break;
      }
   }
   ... // run mark/sweep setting garbage to allocated for reachable blocks
}

Reply via email to