This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Marking smobs for GC


Greg Harvey <Greg.Harvey@thezone.net> writes:

> > You mean, I could just let the proxy/widget move into a guardian when
> > there are no references to it from Scheme and then, after the GC, do
> > the internal reference boogie to find out which of them are really
> > dead and resurrect the rest?  Yes, that could work.  It would be
> > basically the same as what I'm doing now, but probably more efficient.
> 
> Actually, you could just slap it into a guardian from the beginning,
> and look at the dead ones after collection. If they aren't really
> dead, put them back into the guardian. 

I don't know how guardians really work...

> Here's how I understand it: you have a widget foo, that you just
> created. On the gtk side of things, it keeps a reference count; on the
> scheme side of things, you put the scheme object of the widget into
> the widget guardian. You do a bunch of stuff, and then all references
> to foo's scheme object are dropped. On the next collection, foo
> becomes a zombie. After that, you look at the widget zombies. foo
> still has a gtk refcount greater than 1, so you put foo back into the
> guardian.

Almost.  I have to look if that widget has a refcount greater than its
internal refcount, to defeat cycles.  Finding the internal refcount
involves running over all widgets in the guardian, whether zombie or
not.  This can be avoided when there are no zombies in the guardian
which would be a win over the current scheme.  But I think guardians
have their cost, too, no?