caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Damien Doligez <Damien.Doligez@inria.fr>
To: caml-list@inria.fr
Subject: Re:  Finalisation in 2.02
Date: Mon, 13 Dec 1999 13:50:48 +0100	[thread overview]
Message-ID: <199912131250.NAA14523@tobago.inria.fr> (raw)

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

>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.

IIRC, nothing was changed in that part of the system between 2.02 and
2.04.


>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.

(0,1) means "don't change the current GC schedule".  It is appropriate
when the resources used by the block (besides heap memory) are
negligible.  (1,1) means "do a major collection right now".


>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.

That's right.  You could say that "exit" deallocates everything, but
the finalisers are not called for that kind of deallocation, only for
normal deallocation during the program's execution.


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

That would be a workable solution.  But blocks reachable from global
variables still won't be finalised.


> [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]

You should have a look at the Printexc module.  A side effect of using
Printexc.catch is that I/O buffers will be flushed before the program
terminates.

-- Damien




             reply	other threads:[~1999-12-13 16:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-13 12:50 Damien Doligez [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-12-23 17:06 Damien Doligez
1999-12-12  3:38 skaller
1999-12-13  9:35 ` Jacques Garrigue
1999-12-15  8:41   ` Patrick Goldbronn - SYSCO

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199912131250.NAA14523@tobago.inria.fr \
    --to=damien.doligez@inria.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).