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] Native code and stack limit
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-09-10 (12:43)
From: Berke Durak <durak@l...>
Subject: [Caml-list] Native code and stack limit
Some people in my lab complained of not being able to use Ocaml for depth-first
exploring graphs with 1,000,000 or so nodes. Of course the usual remarks about
tail recursion and stack limit have been raised. I decided to check these claims
so I made a small program to depth-first search a random graph with about
80 bytes of intermediary data per node. Including stack space overhead for
some function calls, I think the whole graph sould be explorable in less than
100 * n bytes stack space (rough guess).

It seems that when compiling to native code, the run-time library ignores
both the OCAMLRUNPARAM="l=256M" and Gc.set {(Gc.get()) with Gc.stack_limit
= 64 * 1024 * 1024} instructions. The native-code program systematically aborts
when its process size reaches 64M. I took a look at asmrun/gc_ctrl.c and
the code for adjusting stack size is preprocessed-out. I also have no ulimits
on my machine. Further, running the following code with OCAMLRUNPARAM="l=256M,v=8"

let _ = Gc.set {(Gc.get()) with Gc.stack_limit = 64 * 1024 * 1024}

prints an

Initial stack limit: 1024k bytes
Changing stack limit to 262144k bytes

only if compiled to byte code.

Is there a problem here ? Am I missing something ? I've searched the mailing
list and the frequently asked questions. There's nothing about Stack_overflow
with native code.

Thanks for your help.
Berke Durak
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: