Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Queens examples
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: [Caml-list] Queens examples
> Running the queens and queens_lazy basic examples in OCamlWin gives 
> a stack overflow with board size of 12 x 12.   The queens_lazy 
> example is set-up to do 12 x 12, so it crashes right out of the box.
> Does OCaml often produce such errors?  Is there a trick to preventing
> these errors that was overlooked in writing these examples?

Just to complement the detailed replies already made on this list:
OCaml would happily grow the stack until all the available memory
(physical and virtual) is exhausted.  However, excessive stack
consumption is often the sign of a programming error (recursion that
misses the base case), and exhausting all the memory before reporting
it is not nice, so OCaml implements a soft limit on the size of the
stack.  By default, it's 1 megabyte, but it can be changed from the
command line (the CAMLRUNPARAM variable) or even from within the
program or the interactive system:

        Gc.set {(Gc.get()) with Gc.stack_limit = 4 * 1024 * 1024}

The above bumps the limit to 4 mega-words (16 mega-bytes), and is
enough to run the Queens example with size 12.

Hope this helps,

- Xavier Leroy
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr