Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Dynamic linking, reloading and garbage collection
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nuutti Kotivuori <naked+caml@n...>
Subject: [Caml-list] Dynamic linking, reloading and garbage collection
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