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] Sys.max_array_length
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-02-03 (12:50)
From: Basile Starynkevitch <basile.starynkevitch@i...>
Subject: Re: [Caml-list] Sys.max_array_length
On Tue, Feb 03, 2004 at 01:13:42PM +0100, Sarah DJEBALI wrote:

> I have installed OCAML 3.06 and when executing a program that reads a 
> very long sequence (49 million characters) and puts it into an array, I 
> have got the message :
> Fatal error: exception Invalid_argument("Array.make")

Perhaps you should switch to ocaml-3.07, which is the current release,
which have new interesting features IMHO (but won't solve this
particular problem).

> I understand this is due to a too small value for variable 
> Sys.max_array_length. Does anyone know how to increase it?

The only reasonable way to run your code without changes is to change
your machine to a 64 bit architecture, like AMD64 (aka x86_64) ie
Athlon64 processors or Alpha (or Sparc64).

The maximal array length is wired in a lot of places, and changing it
is not easy, because it is related to the layout of the header word
inside the heap (see the comments inside <caml/mlvalues.h> for

I tend to believe that dealing with very big arrays or strings may
indicate that some parts of your algorithms should be rethought. But I
may be really wrong....

Perhaps you should consider using caml bigarrays (with the ability to
map a file - see documentation of function Bigarray.Array1.map_file at
etc....), or representing your huge data otherwise, eg as lists (or
tuples or arrays) of smaller arrays.

Consider changing some of your datastructures to deal with smaller
arrays! Tell us about your experiments!


Basile STARYNKEVITCH -- basile dot starynkevitch at inria dot fr
Project - INRIA Rocquencourt bat 5 --- all opinions are only mine 

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: