From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 36DA5800FE for ; Tue, 21 Mar 2017 17:06:27 +0100 (CET) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=gabriel.scherer@gmail.com; spf=Pass smtp.mailfrom=gabriel.scherer@gmail.com; spf=None smtp.helo=postmaster@mail-qt0-f174.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.216.174; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.216.174 as permitted sender) identity=mailfrom; client-ip=209.85.216.174; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-qt0-f174.google.com) identity=helo; client-ip=209.85.216.174; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-qt0-f174.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3ATxSaExTwAyQzZrkzxezhF9gintpsv+yvbD5Q0YIu?= =?us-ascii?q?jvd0So/mwa64YBCN2/xhgRfzUJnB7Loc0qyN4v2mBz1LsczJ8ChbNscTB1ld0Y?= =?us-ascii?q?RetjdjKfDGIHWzFOTtYS0+EZYKf35e1Fb/D3JoHt3jbUbZuHy44G1aMBz+MQ1o?= =?us-ascii?q?Ora9QdaK3Iyfntq/8JzLYghOmCH1IfYrdE33/jPqq9IOjIB+BqE0wxrP6jsUKq?= =?us-ascii?q?UFjV9vcGiUmh/94I+a8Zd+4yVL86Y78MtJUKO8dakxUKxZFxwpNmk04IvgshyV?= =?us-ascii?q?HiWV4X5JfWwciBtFB0D+5xH3RJrr+n/1v+Bn2SSee9b9Tb0uVC6K4KJiSRuugy?= =?us-ascii?q?ACYW1quFrLg9B92foI6CmqoAZylsuJOYw=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0B5AwAWT9FYf67YVdFeHAEBBAEBCgEBF?= =?us-ascii?q?QEBAQECAQEBAQgBAQEBhAcxRxIHg1ubboI6lRgqhXgCgwwHQxQBAQEBAQEBAQE?= =?us-ascii?q?BARIBAQkLCwgmMYIzBAEdBYI7AQEBAQIBIx0BGxILAQMBCwYFBAcNDR0CAiEBA?= =?us-ascii?q?REBBQEKEgYTEolZAQMNCA6ddz+MA4IEBQEcgwkFg2cKGScDClWCJAEBAQEBAQE?= =?us-ascii?q?DAQEBAQEBAQEYAgYShjyDZoEJglGCMIJZgl8Fh0IMiA6GKoYQOoIFhHWHGoQyg?= =?us-ascii?q?k+OXoprhywUH4EVDyczciMWH1YXhAcqghA/NYdygU8BAQE?= X-IPAS-Result: =?us-ascii?q?A0B5AwAWT9FYf67YVdFeHAEBBAEBCgEBFQEBAQECAQEBAQg?= =?us-ascii?q?BAQEBhAcxRxIHg1ubboI6lRgqhXgCgwwHQxQBAQEBAQEBAQEBARIBAQkLCwgmM?= =?us-ascii?q?YIzBAEdBYI7AQEBAQIBIx0BGxILAQMBCwYFBAcNDR0CAiEBAREBBQEKEgYTEol?= =?us-ascii?q?ZAQMNCA6ddz+MA4IEBQEcgwkFg2cKGScDClWCJAEBAQEBAQEDAQEBAQEBAQEYA?= =?us-ascii?q?gYShjyDZoEJglGCMIJZgl8Fh0IMiA6GKoYQOoIFhHWHGoQygk+OXoprhywUH4E?= =?us-ascii?q?VDyczciMWH1YXhAcqghA/NYdygU8BAQE?= X-IronPort-AV: E=Sophos;i="5.36,200,1486422000"; d="scan'208,217";a="265541984" Received: from mail-qt0-f174.google.com ([209.85.216.174]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 21 Mar 2017 17:05:53 +0100 Received: by mail-qt0-f174.google.com with SMTP id i34so134648526qtc.0 for ; Tue, 21 Mar 2017 09:05:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=88zP3/VclTYipDefPsS4pRSTUkl2AgKlUkGdUCQWh0c=; b=thIx0SKCPGKfbrraV+m2Q/AZKmgcLYoRlbfOgHiI/VCCbyRabYZKUIV0A7LkG6M9W/ wZJFVYrxSCp8A7MwM76q6vGg4N9DJuBJjBO6sUGlwgjcxmAKeu/bopR5mqII9cP483DD TuqT0g9b5i5r131fWMiQ4Ymf9Hzd/vsLnzUxYIuo4Ef8KJ0vW10BbKUpyUcoMri62tzO DEMl+zHh4D73SQalTCHzmZjIZbH8aLoYex7lG5cOV9wAZm3whY3cJH7gPDq3akpNx1ke nJ8hsp2r8E80JLgXJ0ttgXAwdLQJ4De2VAnZME3xYd7xDzj0IZrwaV6teMWJLZEUxXuh P+Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=88zP3/VclTYipDefPsS4pRSTUkl2AgKlUkGdUCQWh0c=; b=ZLsWI6BkH/RyAPo/9gV7sKsgsBpBGQSEsjz6mik/NS9DxKcWkZ3mSL2UhTLz1nT3i2 uAtLXS5W/TFlVFl7L8S1AgOIuBQ+aH90+NaNtqUdZRqYRSRmrpxpu8jYC1kHnL8Iq0ES jtGUxMHLt+b5POM4XPiivdkc6ZWwVHQBgYpq2M39GqWUBPyCkXvacJ3+KSUtMyzuvmQU J6nHZQhIjsgfDgHdMC85Kq8WCdFP8uvsuifZ2JQ45lIuPZM9TvlGHVBRmHju/cBIHxSC nSn5ml1ueRnXLJYVrrIzOuL9N1rjNy1W0wyb2cY9kJx/NlCAJDCJgTUDwRyvM/T3NKsK P3/A== X-Gm-Message-State: AFeK/H1FBJx9PMeLrb9X/JORGnKQ2bpMfnx/ThIbX/y4VqUQKy8zsZQdT+H3nAqwycxBWfZa3bRCCCogbfax2g== X-Received: by 10.200.49.129 with SMTP id h1mr31940559qte.277.1490112351668; Tue, 21 Mar 2017 09:05:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.156.8 with HTTP; Tue, 21 Mar 2017 09:05:11 -0700 (PDT) In-Reply-To: References: From: Gabriel Scherer Date: Tue, 21 Mar 2017 17:05:11 +0100 Message-ID: To: Romain Beauxis Cc: Max Mouratov , Dmitry Bely , "caml-list@inria.fr" Content-Type: multipart/alternative; boundary=001a11c003866694e6054b3fd12f Subject: Re: [Caml-list] Exceptions and Gc. --001a11c003866694e6054b3fd12f Content-Type: text/plain; charset=UTF-8 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 wrote: > 2017-03-21 6:58 GMT-05:00 Max Mouratov : > > 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 > --001a11c003866694e6054b3fd12f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
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, Ro= main Beauxis <romain.beauxis@gmail.com> wrote:
2017-03-21 6:58 GMT-05:00 Max = Mouratov <max.mouratov@outlo= ok.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 b= indings
>> where some cleanup operations are wrapped up in the finalization >> code with the expectation that, except for a hard crash, it would<= br> >> 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. Bu= t
>> you can write
>> let _ =3D 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.=C2=A0 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

--001a11c003866694e6054b3fd12f--