[redland-dev] implicit free

Maxence Guesdon Maxence.Guesdon at inria.fr
Fri Nov 25 13:09:50 CET 2011


On Fri, 25 Nov 2011 10:36:10 +0000
Norman Gray <norman at astro.gla.ac.uk> wrote:

> 
> Maxence, hello.
> 
> On 25 Nov 2011, at 10:12, Maxence Guesdon wrote:
> 
> > I wonder if freeing the statement also frees the nodes.
> > In fact, I wonder if there is a kind of recursive free through all
> > structures.
> > 
> > Context: I just began an OCaml binding to librdf and I'm trying to play
> > well with the garbage collector.
> 
> See feature request <http://bugs.librdf.org/mantis/view.php?id=365>, and Dave's comments below it, for a potential gotcha here.
> 
> I've implemented a librdf binding for Racket <http://nxg.me.uk/dist/racket-librdf/>, so I've run into the same GC problems as you are (I suspect) about to run into.
> 
> I _believe_ that my code plays nice with the GC.  Possibly, therefore, my wrapper would be of interest to you, even though it's for a different language -- do get in touch if you want to compare notes.

My first guess was to make my own counter for each redland structure
pointer, then decrement this counter when the ocaml value embedding the
pointer was reclaimed by the Gc (when it becomes unreachable).
But since I'm not aware (from the ocaml side) of internal way of handling,
for example, nodes in a statement, I may free, for example, a node even if
it's still referenced internally by a statement.

Since there is a kind a recursive freeing, I may just don't care about C
structure pointers and let the developper use the free functions himself.

Can you tell me what was your approach ?

Regards,

Maxence


More information about the redland-dev mailing list