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
OCaml runtime using too much memory in 64-bit Linux
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-11-14 (17:26)
From: Stefan Monnier <monnier@i...>
Subject: Re: [Caml-list] Re: OCaml runtime using too much memory in 64-bit Linux
> Even on a system like linux, which optimistically allocates memory (i.e. the
> actually underlying memory isn't allocated until you actually touch it),
> once you read the page, it has to actually exist in memory.

It exists in memory: it's the zero page (a page that contains all zero
bytes).  And it's the same physical (RAM) page used for all pages that
have been allocated but not yet written.  So as long as you don't write
to it, it shouldn't use any RAM space.

Of course, it may cost in swap use (depending on optimistic allocation
and the use of MAP_NORESERVE), and it will cost in kernel memory because
the kernel has to maintain the process's page table.

But it seems like a good quick fix, which preserves the advantages of
a dense array of bytes (i.e. fast and simple lookup, compact
representation using less cache space, ...).