Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: [Caml-list] Native compiler support for m68k?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pierre Weis <pierre.weis@i...>
Subject: Re: [Caml-list] GC Question
> in the following kind code :
> let l = ... a function building a long list ... in
> let l' = 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 
> 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
  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,,

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: