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
Re: fancy GC question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-12-15 (12:54)
From: Markus Mottl <mottl@m...>
Subject: Re: fancy GC question
On Tue, 12 Dec 2000, Damien Doligez wrote:
> >When I allocate an integer array in OCaml, which is always boxed, both
> >the pointers to and the elements are obviously contiguous in memory.
> There's no pointer in an integer array.

Ok, they are actually not boxed but tagged (= no pointer) - sorry for
the confusion.

> Heap compaction can move the array and break your code (unless you
> make sure to reset your ar variable after each compaction).  Future
> versions of the GC may move the array under other circumstances.  And
> if your array is small enough and was allocated in the minor heap,
> then the minor GC will move it too.

So (as Xavier mentioned) I have to make absolutely sure that no allocation
can happen during manipulation of the array in C.

> Make sure you really need that performance and understand the
> maintenance cost before using such tricks.

In fact, this piece of code had been in use in the PCRE since the very
beginning without ever causing problems. It is only now that I discovered
that I should better ask whether this is really safe: there is indeed
no allocation there so I can leave it as is and safe the allocation of
an extra array for C, which would otherwise add quite a bit of overhead
in the C-interface.

Best regards,
Markus Mottl

Markus Mottl,,