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
Can GC be BLOCKed?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-12-02 (11:19)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Can GC be BLOCKed?
On Fri, Dec 01, 2006 at 04:39:26PM +0300, Dmitry Bely wrote:
> On 12/1/06, Richard Jones <> wrote:
> >I've only seen two cases where I'd want to stop the GC from running:
> >(1) During quasi real-time operations (eg. a single frame in a game) --
> >this can be solved by making the heap large enough and running the GC
> >at scheduled points.  (2) When the heap is larger than physical RAM --
> >this is solved using our 'Ancient' module.
> I have a main program in C that periodically calls an OCaml function
> and expects the (near) real time response. So I'd like to avoid gc
> inside that function. My current plan is to have another OCaml thread
> that is unfrozen just before returning results to C and does the minor
> (or major - how to decide which one?) garbage collection. Will it
> work?

I guess it'll work - the thing to do is to try it.  I'm wondering why
you need a real time response, and I also hope you're avoiding any
sort of memory allocation on the C side, because malloc and free are
hardly real time functions either.  Many C programmers seem to treat
them as if they were O(1) operations though.


Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology -
Internet Marketing and AdWords courses - - NEW!
Merjis blog - - NEW!