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: Markus Mottl <markus@o...>
Subject: Re: [Caml-list] GC and preventing data relocation
On Fri, 21 Mar 2003, Damien Doligez wrote:
> 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.

Well, I always get headaches when relying on users reading manuals ;-)

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

Of course! Luckily, the C-interface of OCaml is quite convenient and
allows one to handle such cases without problems.

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

Unfortunately, this won't work, because the callback may again call the
C-code, either overwriting the buffer or requiring me to write my own
memory management. I don't think the latter is worthwhile so I'll just
dynamically allocate buffers as required.

Regards,
Markus

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus

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