[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memory managment



>  > > Calling the GC inside a NEW implies that stack and registers are
>  > > checked, otherwise vital root pointers might be ignored and alive
>  > > blocks are discarded.  This suggests that these gcs scan stack and
>  > > registers conservatively.  Can you assert this?  Do they switch to
>  > > precise collection as soon as roots to alive heap objects are
>  > > identified?
>  >
>  > I don't understand what you mean by conservatively.  From my code
>  > perusal it looks like they check that the address in a register or
>  > on the stack is within the range of the allocated memory and then
>  > do some more tests (which I don't understand yet) and finally if
>  > the address passes these tests the block gets marked as still being
>  > used.  This seems pretty agressive to me -- but I dunno.
>  
>  The ETH collector most certainly *isn't* conservative, if I understand the
>  term correctly. It assumes everything that isn't marked is garbage, which
>  makes it a precise collector. This applies even to pointers on the stack
>  and in registers, because it will scan the allocated blocks if necessary to
>  determine if a pointer is valid.

AFAIK a *conservative* collector doesn't rely on tagged pointers, but
rather treats possible memory/stack/register values that could be
pointers (after some validation checks) as such.  A *precise*
collector expects all pointers to be marked as such, there is no need
at all to scan for possible pointers.  An example for such a collector
is the very first ETH GC: Stack and registers are ignored, root
pointers (ie global variables) are marked by the compiler, and type
descriptors hold tables of pointer offsets in heap objects.  
  The second approach makes sure that all reclaimable blocks are
freed.  The first one may accidentally keep an object alive because a
memory location looks like pointer referring to it, although the value
isn't a pointer variable at all (maybe a few characters, or a REAL).
Both approaches (and probably every GC around) discard everything that
isn't marked as garbage.
  IMO scanning stack and registers for possible locations is a
conservative approach, even if the pointers out of heap objects are
traced with the help of type descriptors. 

-- mva