Re: garbage collecting extension types

From: Moises Lejter <mlm_at_cs.brown.edu>
Date: Thu, 4 May 1995 22:33:03 -0400

In article <199505041503.AA13875_at_gwar.mit.edu>, "Jin S. Choi" <jsc_at_gwar.mit.edu> writes:

  jsc> There's something I don't quite understand about the garbage
  jsc> collection. gc_mark_fct is to be called on any SCM objects in
  jsc> your type, right? And gc_sweep_fct is to free up any non-SCM
  jsc> objects and to free the object itself?

Almost. mark is called on any SCM object *that is still reachable*.
sweep is called to clean up any SCM object that was not marked, as
these are the one to garbage-collect.

  jsc> So here's the situation; I have a scheme function that returns one of
  jsc> my new extended types. If I just say
  jsc> (zreceive)
  jsc> I get
  jsc> #<znotice 80392b8>

  jsc> Now I do a (gc) and notice that the sweep function gets called, but
  jsc> not the mark function.

Correct. the result of that function call is not available any
longer, since it is not stored in any data structure that is still
around. GC will then not mark it (no call to mark), so it will
collect it (call to sweep).

  jsc> However, if I do (define foo (zreceive)) and then do a (gc), both
  jsc> sweep and mark functions get called. Is this correct?

This sounds wrong to me. You should have only seen a call to your own
mark function, not to your sweep - since the value returned by
zreceive it sill available (via the global foo).

Moises
Received on Fri May 05 1995 - 04:34:45 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST