guile-user
[Top][All Lists]
Advanced

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

Re: out-of-order GC


From: Neil Jerram
Subject: Re: out-of-order GC
Date: 31 Dec 2002 20:13:34 +0000
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

>>>>> "Egil" == Egil Moeller <address@hidden> writes:

    Egil> The problem thus never araised when there was a referense to
    Egil> the transaction-SMOB, only when there where no reference to
    Egil> neither one any more...

This is identical to the problem that I had in guile-xlib (with
connection -> Display and transaction -> window/pixmap/whatever).
Here is the relevant comment from xlib.c...

/* Note on garbage collection and freeing of X resources.

   The one wrinkle in implementing automatic freeing of X resources is
   that almost all X resources depend on a valid display, so we have
   to be careful that the display resource is always freed (using
   XCloseDisplay) last of all.

   In most cases this is handled by having resource smobs include a
   reference to the display smob.  But there is still a problem when
   all remaining X resource references are dropped between one GC
   cycle and the next: when this happens, the next GC sweep could free
   the display smob before it gets to some of the other resource
   smobs.

   Fortunately, resource smobs can check, in their free functions,
   whether this has happened, by looking at the SCM_TYP16 of their
   reference to the display smob.  If the display smob is still valid,
   this will be scm_tc16_xdisplay, and the relevant X resource should
   be freed as normal.  If the display smob has been freed earlier in
   this sweep, GC will have set its SCM_TYP16 to scm_tc_free_cell;
   this indicates that XCloseDisplay has already been called, and so
   the relevant X resource no longer needs to be freed. */

Regards,
        Neil




reply via email to

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