Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Freeing dynamically loaded code
[ 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: Re: [Caml-list] Freeing dynamically loaded code
skaller@ozemail.com.au wrote:
> That is not enough. It is not necessary for some code to be
> active in order that it may later *become* active as
> a result of a subroutine call or jump. It would be necessary
> to find all code addresses and which blocks they point to,
> and build a dependency graph, and add the roots of that graph
> to the gc memory graph as well.
>
> Otherwise, after you say
>
> 	#load xxxx
>
> the collector would immediately free it :-)

Actually no. The way to access code that is not "active" as you say,
is through global variables. Eg. if you do

   #load "test.cmo"

then there's an entry Test in the global table that holds pointers for
all functions defined in that file. And the global table is inside the
ocaml heap, so those all will be referenced.

The only way for that to become unloaded is that the global Test is
replaced or removed by something - either by some unload module or
loading a newer source on top of it - and then no references point to
Test. And if no references point to the file, it really cannot be
accessed anymore by any means, and hence can be removed.

Ofcourse, right now there might be also other external references to
the code in the heap, I am not sure - but those would have to be
either removed or made Weak somehow. But that is to be solved after
this immediate problem is resolved.

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