[plt-scheme] cyclic structure doesn't get collected

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Aug 22 21:17:31 EDT 2005

At Tue, 23 Aug 2005 00:35:44 +0200, Hans Oesterholt-Dijkema wrote:
> I've a little trouble with mzgtk2. I'm trying to do following:
> 
> 1. scheme_malloced C structure A references Gtk GObject B
> 2. scheme closure X references C structure.A
> 3. structure A references scheme closure X and a function Y  that is 
> part of closure X.
> 
> Let W be scheme closure X.
> 
> I'd now expect:
> 
>   (set! W 10)
>   (collect-garbage)
> 
> To collect structure A, which finalizes closure X and unreferences Gtk 
> GObject B.
> 
> Why does it not work?

For just one pointer, the approximations of conservative GC could get
in the way.

If you have a dozen such X, though, and none of them get collected,
then I agree that something must be wrong.

One way to try to debug this is to configure a build with
--enable-sgcdebug. Then it's possible to use `dump-memory-stats' to
show why the GC thinks that X is still. (Run `(dump-memory-stats)' and
read the end of the output for more info.)

Matthew



Posted on the users mailing list.