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
compiling large file hogs RAM and takes a long time.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-06-08 (01:03)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] Re: compiling large file hogs RAM and takes a long time.
From: Sam Steingold <>
> update: the main problem is a polymorphic variant type with 3050
> variants and a function that returns its instances.
> chunking the type, i.e., replacing
> type foo=[|`A|`B|`C|`D]
> with
> type foo_1=[|`A|`B]
> type foo_2=[|`C|`D]
> type foo=[|foo_1|foo_2]
> (but with ~55 variants in ~55 types) did not help.
> Removing the type definition did solve the RAM problem - according to
> top(1), ocamlopt.opt was taking ~80MB, and it compiled the file in about
> 10 minutes.
> Any chance there is some quadratic code in polymorphic variant type
> processing?!

There is, and this is a known problem:

I'm sorry, but I don't see any easy way out.
At least on the basic time complexity.
However, the space complexity could be improved, if I find what is
gobbling memory so fast.