caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Romain Beauxis <romain.beauxis@gmail.com>
Cc: Max Mouratov <max.mouratov@outlook.com>,
	Dmitry Bely <dmitry.bely@gmail.com>,
	 "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] Exceptions and Gc.
Date: Tue, 21 Mar 2017 17:05:11 +0100	[thread overview]
Message-ID: <CAPFanBHn+PrGFBEwCGfTGLhQjpyo+itxVjs1V-40wCLYcxPf3g@mail.gmail.com> (raw)
In-Reply-To: <CABWZ6OQhCj9eErD7Fhng=JQtsCo7xU04veanZEOsW6kxs30LyQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2045 bytes --]

By the way, the unloading patch is now merged. (In trunk; it should not be
part of the 4.05 release in preparation, but of 4.06 that should hopefully
happen six months after that.)

On Tue, Mar 21, 2017 at 4:07 PM, Romain Beauxis <romain.beauxis@gmail.com>
wrote:

> 2017-03-21 6:58 GMT-05:00 Max Mouratov <max.mouratov@outlook.com>:
> > Tuesday, March 21, 2017, 12:22:54 AM, Romain wrote:
> >> The reason I'm asking if that I know I've been writing C bindings
> >> where some cleanup operations are wrapped up in the finalization
> >> code with the expectation that, except for a hard crash, it would
> >> always be executed at some point in the future..
> >
> > Tuesday, March 21, 2017, 4:17:05 PM, Dmitry wrote:
> >> It has nothing to do with exceptions. The problem is that OCaml
> >> runtime does not execute the garbage collector on program exit. But
> >> you can write
> >> let _ = at_exit Gc.full_major
> >> if you need to force GC.
> >
> > It won't guarantee running all finalisers, as some of the objects may
> > still be reachable. As part of a yet unmerged patch [1] that will land
> > in 4.06, I have added an option that makes the runtime shut down
> > properly on process exit (by an implicit call to the new caml_shutdown
> > function), but unfortunately it doesn't handle Gc.finalise yet, as the
> > relevant logic is not so trivial (and is probably a subject for a
> > different PR). However, custom blocks [2] are guaranteed to be
> > finalised properly with caml_shutdown, so you might look into this.
>
> Thanks guys.
>
> That patch sounds great. I was just wondering since after all this
> time writing OCaml I never thought about it nor actually ready
> anything about this topic.
>
> Being able to clean everything up when the program exits seems like a
> reasonable feature.
>
> Romain
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

[-- Attachment #2: Type: text/html, Size: 3038 bytes --]

  reply	other threads:[~2017-03-21 16:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-20 19:22 Romain Beauxis
2017-03-21 11:17 ` Dmitry Bely
2017-03-21 11:58   ` Max Mouratov
2017-03-21 15:07     ` Romain Beauxis
2017-03-21 16:05       ` Gabriel Scherer [this message]
2017-03-25 11:11       ` SP

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=CAPFanBHn+PrGFBEwCGfTGLhQjpyo+itxVjs1V-40wCLYcxPf3g@mail.gmail.com \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=dmitry.bely@gmail.com \
    --cc=max.mouratov@outlook.com \
    --cc=romain.beauxis@gmail.com \
    /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).