From: Romain Beauxis <romain.beauxis@gmail.com>
To: Max Mouratov <max.mouratov@outlook.com>
Cc: 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 10:07:50 -0500 [thread overview]
Message-ID: <CABWZ6OQhCj9eErD7Fhng=JQtsCo7xU04veanZEOsW6kxs30LyQ@mail.gmail.com> (raw)
In-Reply-To: <VI1PR0901MB1312C075F1E5E89F7F717A14BF3D0@VI1PR0901MB1312.eurprd09.prod.outlook.com>
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
next prev parent reply other threads:[~2017-03-21 15:08 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 [this message]
2017-03-21 16:05 ` Gabriel Scherer
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='CABWZ6OQhCj9eErD7Fhng=JQtsCo7xU04veanZEOsW6kxs30LyQ@mail.gmail.com' \
--to=romain.beauxis@gmail.com \
--cc=caml-list@inria.fr \
--cc=dmitry.bely@gmail.com \
--cc=max.mouratov@outlook.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