From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA20740; Thu, 11 Dec 2003 18:00:39 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA20729 for ; Thu, 11 Dec 2003 18:00:38 +0100 (MET) Received: from smtp3.pp.htv.fi (smtp3.pp.htv.fi [213.243.153.173]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hBBH0br02745 for ; Thu, 11 Dec 2003 18:00:38 +0100 (MET) Received: from posti.pp.htv.fi (posti.pp.htv.fi [212.90.64.50]) by smtp3.pp.htv.fi (Postfix) with ESMTP id 45E6D27AE82 for ; Thu, 11 Dec 2003 19:00:37 +0200 (EET) Received: from oro (aka.pp.htv.fi [213.243.183.115]) by posti.pp.htv.fi (8.11.1 (Revision 1.5+JAGae91741+JAGae92668) /8.11.1) with ESMTP id hBBH0aT24519 for ; Thu, 11 Dec 2003 19:00:36 +0200 (EET) Received: from naked by oro with local (Exim 3.36 #1 (Debian)) id 1AUUB0-0007cL-00 for ; Thu, 11 Dec 2003 19:00:34 +0200 To: caml-list@inria.fr Subject: [Caml-list] Dynamic linking, reloading and garbage collection From: Nuutti Kotivuori Date: Thu, 11 Dec 2003 19:00:32 +0200 Message-ID: <87llpj9tn3.fsf@naked.iki.fi> User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Loop: caml-list@inria.fr X-Spam: no; 0.00; reloading:01 dynamically:01 dynlink:01 loadfile:01 loadfile:01 dynlink:01 stdout:01 stdout:01 eats:01 cmo:01 ocaml:01 caml:01 garbage:01 interfaces:01 segmentation:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I am thinking of a system where I would be dynamically loading files, repeatedly in a long-lived OCaml process. But I am a bit uncertain how things are handled. Let's just assume Dynlink.loadfile_private for now - since loadfile seems to open up a can of worms I'd rather not deal with, including segmentation faults if interfaces change. What is actually changed when I do Dynlink.loadfile_private? What happens when I do Dynlink.loadfile_private again on the same file? Assuming also that the file could have changed in the meanwhile. Atleast something is left behind right now. If I do: ,---- | Dynlink.init ();; | Gc.print_stat stdout;; | for i = 0 to 50000 do | Dynlink.loadfile_private "test.cmo"; | done;; | Gc.compact ();; | Gc.print_stat stdout;; `---- I find that the process eats 20 megs of memory after loading the file 50000 times. And if I change that to be 100000 times, I get a fatal exception of Stack_overflow. This is a bit worrying, since it might have to scale up to 100000 different files some day as well. So what gives? Or should I just read the source more? -- Naked ------------------- 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