Re: Finalisation in 2.02

From: Jacques Garrigue (Jacques.Garrigue@inria.fr)
Date: Mon Dec 13 1999 - 10:35:38 MET


To: skaller@maxtal.com.au
Subject: Re: Finalisation in 2.02
In-Reply-To: Your message of "Sun, 12 Dec 1999 14:38:03 +1100"
        <3853189B.86E5EBFE@maxtal.com.au>
Message-Id: <19991213103538V.garrigue@pauillac.inria.fr>
Date: Mon, 13 Dec 1999 10:35:38 +0100
From: Jacques Garrigue <Jacques.Garrigue@inria.fr>

From: skaller <skaller@maxtal.com.au>

> The problem is that when I create an object with alloc_final(_,_,0,1),
> the finaliser is not called on termination. Using 1,1 seems to cause
> it to be called almost immediately.

The meaning of the two last parameters is a fraction giving the
maximum number of times allocation may be done before GC is
called. 0/1 means that the GC urgency count is not incremented, so
this may take an indefinite time. 1/1 means do GC on each allocation.

As an example, in LablGtk all widgets allocations are finalized, with
a parameter 1/200. That is, the GC will be called at least every 200
times I build a pointer to a GtkObject, so that I may not have more
than 200 stall pointers. This may need some more tuning, but the
number of pointers you create depends very much on your application.

If you want to try it on mlgtk, I suggest you have a look at how it is
done in LablGtk, since it seems to work ok, and this kind of things
(interaction between normal GC and reference counting GC) may be
bug-prone.

(You may also choose to switch to lablgtk, since it will work on the
next version of ocaml :-)

> Perhaps I should force a full GC collection, just before
> termination?

I don't think you need to do it. Reference counting is just to
deallocate unused resources in long running programs, it does not
change anything in your interaction with the program.

Regards,

Jacques
------------------------------------------------------
Jacques Garrigue, visiting INRIA from Kyoto University
                          Jacques.Garrigue at inria.fr



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:29 MET