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
[Caml-list] [PATCH] Dynamic freeing of dynamically loaded code
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-12-22 (13:26)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] [PATCH] Dynamic freeing of dynamically loaded code
On Mon, Dec 22, 2003 at 09:55:40AM +0200, Nuutti Kotivuori wrote:
>  - If the module defines any toplevel functions, it cannot ever be
>  freed, because the closures are referenced from the global
>  table. This is true even for loadfile_private. Eg. code that defines
>  functions will still not be garbage collected.

Does this apply to:

let () = ...

code?  I assume these aren't really "toplevel functions".

More seriously, what about toplevel functions which aren't referenced
outside the code (they may even be made private using an .mli file).
I have a LOT of code which does this sort of thing:

let run r =
  let q = new cgi r in

  (* ... blah blah the CGI script ... *)

(* Register the script's run function. *)
let () =
  register_script run

The toplevel 'run' function is there, but never referenced directly
from outside the code, although of course it is called from outside
the code.


Richard Jones.
Merjis Ltd. - improving website return on investment
C2LIB is a library of basic Perl/STL-like types for C. Vectors, hashes,
trees, string funcs, pool allocator:

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