guile-user
[Top][All Lists]
Advanced

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

Weak references and GC


From: Neil Jerram
Subject: Weak references and GC
Date: Wed, 07 Sep 2005 23:43:29 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

I'm having trouble with lists (actually source code expressions) that
are weakly stored in several places and never being GC'd.  I wondered
if anyone on the list might be able to spot a problem in the following
description.

This is to do with my work on breakpoints, so each list here is a read
code expression that the user wants to set a breakpoint on.

Each such list is stored:

- in the source weak hash (scm_source_whash), which is used for
  storing source properties, including the breakpoint flag

- in a weak hash (created by make-object-property) that I use for
  mapping each list to my breakpoint object

- in a guardian (greedy, because I'm using Guile 1.6 and greedy is the
  default there), so I can discover when the list is GC'able

- as an element in a weak vector which hangs off the breakpoint
  object, so I can reference from the breakpoint to the source
  expression.

These should all be weak references, but it appears that the list is
never GC'd - by which I mean that

- the guardian never returns the list to me when I call it

- the relevant weak hash and vector cells never disappear (or change
  to #f).

Any ideas?  I'm pretty certain that the list is GC'able apart from
these weak references.

I wonder about the details of the interaction between the guardian and
the weak references.  What I would like to happen is this:

- The first time that the list is deemed to be GC'able, the guardian
  is flagged to return it (when called), and the list then becomes
  non-GC'able.  The weak hash and vector cells should _not_ be cleared
  at this point.

- Some time after the guardian has been called, and dropped the list
  reference, the GC is run again.  The list is deemed to be GC'able
  again, and this time there is no guardian, so the weak hash and
  vector cells are cleared and the list is freed.

Does anyone know if this matches what the code implements?  (I'm not
suggesting that it doesn't - I haven't bothered to look and try to
work it out yet.)

Final question: are there any cunning techniques for debugging why an
object is not GC'd?

Regards,
        Neil





reply via email to

[Prev in Thread] Current Thread [Next in Thread]