caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pierre Weis <pierre.weis@inria.fr>
To: christophe.raffalli@univ-savoie.fr (Christophe Raffalli)
Cc: Damien.Doligez@inria.fr, caml-list@inria.fr
Subject: Re: [Caml-list] GC Question
Date: Tue, 9 Sep 2003 11:32:01 +0200 (MET DST)	[thread overview]
Message-ID: <200309090932.LAA05613@pauillac.inria.fr> (raw)
In-Reply-To: <3F5CE84F.4030609@univ-savoie.fr> from Christophe Raffalli at "Sep 8, 103 10:36:31 pm"

> in the following kind code :
> 
> let l = ... a function building a long list ... in
> let l' = List.map fn l in (* or fold or anything similar *)
> ... no more reference to l ...
> 
> Once the beginning of l has been read to compute l' (assuming List.map 
> starts from the beginning of l) is the GC able to collect the beginning 
> of l ?

No it cannot since, AFAIK, l is not freed (i.e. assigned to 0) into
the stack (or local environment) before you leave the block where your
code occurs (normally the activation block of the function where it
appears in).

> If not how to write the code to ensure this behaviour of the GC ?
>
> Christophe Raffalli

Do not use let bindings, write function applications or function
compositions instead.
 (Instead of writing
  let l1 = f l0 in
  let l2 = g l1 in
  h l2
  write
  let i l = h (g (f l)) in
  i l0)

Alternatively, use explicit references to lists and free them
explicitely in your code ! This is tractable when the flow of control
of the code is simple enough (for instance in the case of a
clear succession of passes where data from previous passes are clearly
unused in the following steps).

Hope this helps,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-09-09  9:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20030820104917.GB6782@linux-m68k.org>
2003-08-20 12:32 ` [Caml-list] Native compiler support for m68k? Xavier Leroy
2003-08-20 17:46   ` Gleb N. Semenov
2003-08-21 14:56     ` Xavier Leroy
2003-08-21 19:32       ` Daniel M. Albro
2003-08-24 20:05   ` Richard Zidlicky
2003-08-26 13:43     ` Xavier Leroy
2003-08-30  9:59   ` Richard Zidlicky
2003-09-05 21:58   ` Richard Zidlicky
2003-09-06  0:53     ` Byron Hale
2003-09-06 10:01     ` Benjamin Geer
2003-09-07 13:37     ` David MENTRE
2003-09-08  9:52     ` Damien Doligez
2003-09-08 20:36       ` [Caml-list] GC Question Christophe Raffalli
2003-09-09  9:32         ` Pierre Weis [this message]
2003-09-09 10:40           ` Christophe Raffalli
2003-09-11 15:04         ` Xavier Leroy
2005-07-05  7:59 GC question dmitry grebeniuk
2005-07-06  7:29 ` [Caml-list] " Jean-Christophe Filliatre
2005-10-24 17:53 MATTHEW HAMMER
2005-10-25 18:41 ` [Caml-list] " Damien Doligez
2005-10-25 19:20   ` MATTHEW HAMMER
2005-10-27 14:25     ` Damien Doligez

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=200309090932.LAA05613@pauillac.inria.fr \
    --to=pierre.weis@inria.fr \
    --cc=Damien.Doligez@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=christophe.raffalli@univ-savoie.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).