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] embedded caml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-11-11 (17:24)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] embedded caml?
> I am trying to get O'Caml to run in an extremely resource constrained
> environment.   To this end I am interested in getting the O'Caml
> program to run in as small a memory footprint as possible (GC induced
> latencies are not a problem).
> Today using OCaml 3.02 on FreeBSD 4.3, a simple hello world program 
> like, >> print_endline "Hello World";; << translates to
>         o 8554 bytes of interpreter bytecode, and,

The ocaml bytecode linker, like the C linker, eliminates unused
compilation units; but as soon as you reference a function from the
Pervasives unit (e.g. print_endline), all of Pervasives gets linked
in.  It is possible to construct a lightweight version of the standard
library, and/or bypass its use altogether.  With that kind of hacks
you could get to less than 1K for "hello world".

>         o 111945 bytes of executable code (using the -custom switch to
>           "ocamlc")

Same answer.  Some of the runtime system services (e.g. marshalling,
debugger interface, etc) can be eliminated if you don't need them.
However, more than half of these 111K are composed of the bytecode
interpreter and the GC / memory manager; you can't eliminate those :-)

> I would like to ask if anyone has considered Caml for embedded 
> applications?  

I don't think this has been considered much (unless you count as
"embedded" the Palm Pilot port of Caml Light that François Rouaix did
a while ago).  

Generally speaking, I think Caml (and especially the Objective Caml
implementation) is not really suitable if you don't have a 32-bit processor
and at least a few hundred kilobytes of RAM.  If your memory
constraints are tighter than this, I'm afraid a lower-level language
is required.

- Xavier Leroy
Bug reports:  FAQ:
To unsubscribe, mail  Archives: