Finalisation in 2.02

From: skaller (skaller@maxtal.com.au)
Date: Sun Dec 12 1999 - 04:38:03 MET


Date: Sun, 12 Dec 1999 14:38:03 +1100
From: skaller <skaller@maxtal.com.au>
To: caml-list@inria.fr
Subject: Finalisation in 2.02

I'm still using ocaml 2.02, and have encountered what looks like a bug,
although perhaps it is my understanding, and perhaps it is fixed
in 2.04, or will be in 3.

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. [I seem to also get this
behaviour with output to stdout -- I have to flush the file
after every write, in case an exception terminates the program,
and these debugging writes are there precisely to track this]

I'm modifying mlgtk by boxing GtkObjects, this seems necessary
to allow the collector to call the finaliser which decrements
the reference count -- however, at least the memory of the object
doesn't seem to be released when caml terminates.

Does 0,1 mean 'never bother calling the finaliser,
there is nothing to finalise'? That makes mathematical
sense (but isn't what I expected, since the documentation
advises to use this setting if you aren't sure).

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

BTW: I would like to reinforce comments that ocaml is
easy to interface! In fact, it is easier than Python
or Tcl (I have extensive experience with both).
I don't claim to really understand everything yet --
but I seem to be able to get code working very quickly.

-- 
John Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
voice: 61-2-9660-0850



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