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] Suggestion: a possible alternative to shared libraries?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-06-14 (14:23)
From: Benjamin Geer <benjamin.geer@m...>
Subject: [Caml-list] Suggestion: a possible alternative to shared libraries?
The pros and cons of being able to create shared libraries in Caml have 
been abundantly discussed on this list.  I've been thinking about the 
reasons why I originally thought it would be a good idea[1], and Xavier 
Leroy's very reasonable objections[2], and then I read about this 
enhancement which Sun has added to its 1.5 JVM:

(I've included the most relevant bits of that page at the bottom of this 

Reading this, it occurred to me to ask whether a similar approach might 
provide similar benefits for Caml.

The reasoning is as follows: if many small programs use the same large 
library, each of the small programs will require a lot of memory. 
Rather than create shared libraries to get around this, the idea is to 
write the in-memory representation of libraries (ideally on an as-needed 
basis) into a cache consisting of one or more files that can be mapped 
read-only into memory; that memory could then be shared by multiple Caml 
processes that needed to use the same libraries.

Perhaps Caml's existing MD5 signatures for libraries could be used to 
distinguish between an older version of a library and a newer one, so 
each Caml process would only memory-map the version that it was 
originally linked with, in order to avoid the "DLL hell" problem that 
Xavier points out.

Could someone in the Caml development team tell me whether this is a 
completely crazy idea?





[Description of the Sun JVM enhancement:]

When the JRE is installed on
supported platforms using the Sun provided installer, the installer
loads a set of classes from the system jar file into a private
internal representation, and dumps that representation to a file,
called a "shared archive".... During subsequent JVM invocations, the 
shared archive is memory-mapped in, saving the cost of loading
those classes and allowing much of the JVM's metadata for these
classes to be shared among multiple JVM processes....

The footprint cost of new JVM instances has been reduced in two ways.
First, a portion of the shared archive, currently between five and six
megabytes, is mapped read-only and therefore shared among multiple JVM
processes. Previously this data was replicated in each JVM instance.
Second, less data is loaded out of the shared archive because the
metadata for unused methods remains completely untouched as opposed to
being created and processed during class loading. These savings allow
more applications to be run concurrently on the same machine.

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