storing highly shared data structures

Simon Marlow simonmar at
Wed Jan 11 08:58:52 EST 2006

Esa Ilari Vuokko wrote:
> On 1/11/06, Christian Maeder <maeder at> wrote:
>>Simon Marlow wrote:
>>>You can change the allocation area size from within a program quite
>>>easily.  Write a little C function to assign to
>>>RtsFlags.GcFlags.minAllocAreaSize (#include "RtsFlags.h" first), and
>>>call it from Haskell; the next time GC runs it will allocate the larger
>>>nursery.  Please try this and let me know if it works.
>>Can someone supply a code snippet for me (as I don't speak C and always
>>hoped to avoid C by using haskell)?
> Hi
> Following compiles and runs for me (ghc 6.4.1), but I didn't test any effects.
> C-bits:
> #include "Rts.h"
> #include "RtsFlags.h"
> void SetMinAllocArea(int a) {
>     RtsFlags.GcFlags.minAllocAreaSize=a;
> }
> Haskell bits:
> import Foreign.C.Types
> foreign import ccall "SetMinAllocArea" setMinAllocArea :: CInt -> IO ()
> It requires compiling c-bits without --make, something like
> ghc -c bits.c -o bits.o
> and including it on final linking or --make step (or ar/ld, similary)
> ghc bits.o --make main

I forgot to mention, minAllocAreaSize is in units of BLOCK_SIZE, so 
divide bytes by BLOCK_SIZE before setting it.  You can get BLOCK_SIZE 
from Rts.h.


More information about the Glasgow-haskell-users mailing list