Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] GC and preventing data relocation
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Damien Doligez <damien.doligez@i...>
Subject: Re: [Caml-list] GC and preventing data relocation
On Thursday, March 20, 2003, at 04:16 PM, Markus Mottl wrote:

> Since there is no way for me to tell the C-library to continue with a
> new location of the string, I'd like to know whether there is any way
> to prevent the GC from moving specific data?

In the current implementation (and in the foreseeable future), if your
string is in the major heap, then only the compactor can move it.
You could try to disable the automatic compaction (by setting
max_overhead to 1 million) during the callback, restoring the
original setting when you get out of the callback.  You'll have
to tell your users that they must not call Gc.compact nor change
max_overhead during the execution of the callback function.

You will also have to correctly manage the case where the callback
function raises an exception...

If the string is in the minor heap, you know it's a short string
and you can (for example) copy it into a buffer pre-allocated in
the C heap.

-- Damien

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