[gclist] Question from a newbie

Wang, Daniel Chen-An (Dan) dcwang@agere.com
Wed, 7 May 2003 10:49:49 -0400


At 12:14 AM 5/7/2003, Emery Berger wrote:
> From the FAQ: http://www.iecc.com/gclist/GC-algorithms.html#Jargon
>
>garbage
>Data that is not reachable.

http://citeseer.nj.nec.com/goldberg92polymorphic.html

That definition of garbage is too weak to properly describe what Goldberg's 
"garbage collector" does. I should try to get my nit-pick put in the FAQ. :)
Also note that region-based type systems used by Tofte-Talpin can reclaim 
"reachable garbage".

http://citeseer.nj.nec.com/tofte97regionbased.html

Seciton 4 of

  http://citeseer.nj.nec.com/morrisett97semantics.html

defines garbage in a more semantic way independent of reachability.

In practice "data which is not reachable" begs the question of what should 
be  reachable!

For example:
void m1() {
Object obj1 = ...;
Object obj2 = ...;
   m2();
  return obj2;
}

void m2() {
  /* gc gets invoked */
}

When m2 is called an the gc is invoked is obj1 reachable?  Well that 
depends on whether or not the compiler spilled the obj1 variable on the 
stack or nulled out it's register holding the value. Intuitively obj1 is 
garbage, because we don't touch it after we return from m2. In fact a good 
compiler should sprinkle enough information in the stack frames so that 
even though obj1 may be on the stack the GC doesn't trace it. Obviously, 
the compiler and the programer have a more interesting "semantic" 
definition of what is and isn't "garbage". This notion of "garbage" is not 
at all tied to reachablity.