Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2003-03-21 (16:35)
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.


Markus Mottl                                   
Austrian Research Institute
for Artificial Intelligence        

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: