<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/12/b218a258251a78c1b945b8dfd7846220"
  from="Nuutti Kotivuori &lt;naked+caml@n...&gt;"
  author="Nuutti Kotivuori"
  date="2003-12-11T17:00:39"
  subject="[Caml-list] Dynamic linking, reloading and garbage collection"
  prev="2003/12/273818949a6b419c61c9cef3c10d64bf"
  next="2003/12/e195f6e7eda781eca277d9793ce36f26"
  prev-thread="2003/12/23761d3eb8a5f461976c2334cc53cb1c"
  next-thread="2003/12/e195f6e7eda781eca277d9793ce36f26"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Dynamic linking, reloading and garbage collection">
<msg 
  url="2003/12/b218a258251a78c1b945b8dfd7846220"
  from="Nuutti Kotivuori &lt;naked+caml@n...&gt;"
  author="Nuutti Kotivuori"
  date="2003-12-11T17:00:39"
  subject="[Caml-list] Dynamic linking, reloading and garbage collection">
</msg>
</thread>

<contents>
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

</contents>

</message>

