RE: sgml-parse and GC

Subject: RE: sgml-parse and GC
From: Peter Nilsson <pnidv96@xxxxxxxxxxxxxx>
Date: Sat, 24 Jul 1999 12:31:35 +0200 (CEST)
Hi, Avi,

On Fri, 23 Jul 1999, Avi Kivity wrote:

> On Thursday, July 22, 1999 22:28, Peter Nilsson
> [SMTP:pnidv96@xxxxxxxxxxxxxx] wrote:
> > On Thu, 22 Jul 1999, Avi Kivity wrote:
> > 
> > > On Thursday, July 22, 1999 18:07, Peter Nilsson
> > > [SMTP:pnidv96@xxxxxxxxxxxxxx] wrote:
> > > > 
> > > > Hopefully, the reference counting mechanism will keep the nodes in
> > > > memory
> > > > as long as necessary, but I'm not sure.
> > > 
> > > It will, and thus defeat your intent.
> > > 
> > The reason I wasn't sure was that there certainly is cycles in the grove
> > and I haven't check how this problem is solved. (Reference counting
> > doesn't work with circular links, but this is a wellknown fact.) However
> > this is probably solved; I can check out how it's done myself:-)
> 
> A tracing garbage collector is used, which can remove cycles. I implicitly
> understood you to mean the garbage collector when you talked about reference
> counting (see Subject: line).
> 

[Yes, I choose a bad subject line]

We are talking about two things at the same time I'm afraid:
1) The expression language objects (ELObj derivatives in OpenJade).
They're collected, as you describe above, by the Collector class
(inherited by INterpreter).

2) The grove implementation with Node, NodePtr and so on. Objects in this
implementation are not garbage collected. Instead reference counting is
used.

The link between these is that, for example, the NodePtrNodeListObj
(derived from ELObj) has a NodePtr member (called node_). So when an
NodeListPtrObj is GC'ed, the NodePtr is destroyed and the Node pointed to
by that object gets is refcounter decremented. (There are other
NodeListObj:s as well as NodePtrNodeList Obj, for node lists (other than
singelton) and making up the lazy implementation of node lists in
OpenJade, but this is another discussion.)

What I didn't know was how a GroveImpl object could be destroyed when none
of its nodes were used since the grove contains cycles (for example, every
node has a reference to the grove root). Now I've checked in the spgrove
implementation and think I found out how it works. So, if I understand it
right, the grove is removed when no nodes in it are used (but it isn't
garbage collected; instead refcounters are used.)

Regards,
/Peter Nilsson

--
'(?P . (?e . (?t . (?e . (?r)))))


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread