Version française
Home     About     Download     Resources     Contact us    
Browse thread
Finalisation in 2.02
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <Jacques.Garrigue@i...>
Subject: Re: Finalisation in 2.02
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