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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 1AD217F02D for ; Tue, 7 Oct 2014 10:09:31 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of nicolas.boulay@gmail.com) identity=pra; client-ip=209.85.223.175; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas.boulay@gmail.com"; x-sender="nicolas.boulay@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of nicolas.boulay@gmail.com designates 209.85.223.175 as permitted sender) identity=mailfrom; client-ip=209.85.223.175; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas.boulay@gmail.com"; x-sender="nicolas.boulay@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ie0-f175.google.com) identity=helo; client-ip=209.85.223.175; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas.boulay@gmail.com"; x-sender="postmaster@mail-ie0-f175.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArABAGqfM1TRVd+vlWdsb2JhbABfg2FYBIJ+uEiPLoFth02BBwgWAREBAQEBBw0JCRIuhAQBAQMBEhEdAS0LAQMBCwEFBQQHGh0CAiISAQUBChIGExIQiAgDCQgNoCFuizCFAohKJwMKhwsSAQUOkDODAoFUBYUVBZEWhw6BaJImGCmBbIMqOy8BgkkBAQE X-IPAS-Result: ArABAGqfM1TRVd+vlWdsb2JhbABfg2FYBIJ+uEiPLoFth02BBwgWAREBAQEBBw0JCRIuhAQBAQMBEhEdAS0LAQMBCwEFBQQHGh0CAiISAQUBChIGExIQiAgDCQgNoCFuizCFAohKJwMKhwsSAQUOkDODAoFUBYUVBZEWhw6BaJImGCmBbIMqOy8BgkkBAQE X-IronPort-AV: E=Sophos;i="5.04,668,1406584800"; d="scan'208";a="82230650" Received: from mail-ie0-f175.google.com ([209.85.223.175]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 07 Oct 2014 10:09:29 +0200 Received: by mail-ie0-f175.google.com with SMTP id x19so4737752ier.6 for ; Tue, 07 Oct 2014 01:09:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=e+J6q3ZCSYim6WCezB5APhy7VHsZlUdUrLWFiO5xJSc=; b=IvLXkEashMuha0HOLGNEmawHNvp5nY2TdMdJpaIgaADwELySRJjZOsE75/NElnNNqY 9BS7LYtXEHt/YpH7auMIwNMJGnVOGLHqHW5qQZBBQgQlzIGB2Fng5KW2qwPwZ5t0pIrj r0+mNW4wIvAOJNSzwYB783LKCDVgqEVgjMVWX40S/GwlNGxpjUYIMFxUye27vT3IPkqN 1le4Dnj4jQF6BuOP1rIrTJB7PpYANXW0GKfVgzWC68u18GhBwjMhUVncQx7xbUWh1Rhi yx4rZsTSYEBXCdUn0uH4pcs3NUQP3KgfGCVA/yRQd1iefi9i816ma+neAN3BX0c8MIzW p/Mw== MIME-Version: 1.0 X-Received: by 10.50.66.170 with SMTP id g10mr2991031igt.10.1412669368570; Tue, 07 Oct 2014 01:09:28 -0700 (PDT) Sender: nicolas.boulay@gmail.com Received: by 10.50.28.44 with HTTP; Tue, 7 Oct 2014 01:09:28 -0700 (PDT) In-Reply-To: References: Date: Tue, 7 Oct 2014 10:09:28 +0200 X-Google-Sender-Auth: nhhB5wQgGpVUrzSefQQ7o5LGA8k Message-ID: From: Nicolas Boulay To: Damien Pous Cc: caml-list Content-Type: multipart/alternative; boundary=047d7bdc07aee61a800504d0b764 X-Validation-by: nicolas@boulay.name Subject: Re: [Caml-list] hook before gc major collections --047d7bdc07aee61a800504d0b764 Content-Type: text/plain; charset=UTF-8 Why do you not use "weak" pointer semantic ? http://caml.inria.fr/pub/docs/manual-ocaml/libref/Weak.html 2014-10-07 10:05 GMT+02:00 Damien Pous : > Hello, > > Is there a way to register a function, to be called before each gc > major collection ? > (I have some cache tables which I'd like to empty from time to time - > I'm not sure this is a good idea, but I would like to experiment it.) > > I see two related functions in the std lib, but not the precise thing I > want: > - Gc.create_alarm, to register a function to be called *after* such > collections ; > - Gc.finalise, which I could use with a dummy heap allocated value, > but then I guess my function would be called before any gc *minor* > collection, which is certainly too often in my concrete use-case. > > Thanks in advance, > Damien > > -- > 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 > --047d7bdc07aee61a800504d0b764 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Why do you not use "weak" pointer semantic ?
= htt= p://caml.inria.fr/pub/docs/manual-ocaml/libref/Weak.html

2014-10-07 10:05 GMT+0= 2:00 Damien Pous <Damien.Pous@inria.fr>:
Hello,

Is there a way to register a function, to be called before each gc
major collection ?
(I have some cache tables which I'd like to empty from time to time - I'm not sure this is a good idea, but I would like to experiment it.)
I see two related functions in the std lib, but not the precise thing I wan= t:
- Gc.create_alarm, to register a function to be called *after* such
collections ;
- Gc.finalise, which I could use with a dummy heap allocated value,
but then I guess my function would be called before any gc *minor*
collection, which is certainly too often in my concrete use-case.

Thanks in advance,
Damien

--
Caml-list mailing list.=C2=A0 Subscription management and archives:
ht= tps://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

--047d7bdc07aee61a800504d0b764--