Re: GC and GTK+
- From: Owen Taylor <otaylor gtk org>
- To: gtk-list redhat com
- Subject: Re: GC and GTK+
- Date: 20 Apr 1998 14:17:28 -0400
Ulric Eriksson <firstname.lastname@example.org> writes:
> On Sun, 19 Apr 1998, Owen Taylor wrote:
> > - Does GC solve multi-language memory management problems?
> > Not unless the same GC system is used for all languages. A cycle
> > that traverses two languages cannot be found unless the garbage
> > collector can walk the heap in both systems.
> Certainly one can have different GC systems for different languages,
> otherwise the problem becomes almost unsolvable (what will be rewritten to
> fit the 'there can be only one' system).
> In SIAG, SIOD and Guile (and Tcl) coexist nicely, each doing its own GC.
> Gtk should handle its own resource management and do it well, anything
> more is probably too much.
The problem is that GTK's situation is much more complicated
than something like SIAG.
In many circumstances when mixing languages, you are only
using objects form one language in another. With GTK objects
the ability to attach callbacks means that GTK objects
used in a language become part of the languages memory
Another way of putting it, is that callbacks allow you to
refer not only _to_ and object in several languages, but
_from_ an object in several languages.
Which means that you can have loops such as:
LSO A <====> GTKO A (parent)
LSO B <====> GTKO B (child)
Which are simply impossible to detect without a unified
GC scheme. This is why GTK has a manual destruction step
that in non-pathalogical cases breaks enough links to
But being 100% correct is impossible. Which really shows,
that as you say, doing more than handling GTK's own
memory management well (and providing hooks for language
bindings) is probably too much.
] [Thread Prev